blob: f7b43f6b7f9363d16dfc5b373a0e3c082ee64e33 [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
Gilles Peskinefd8332e2017-05-03 16:25:07 +02001797requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
1798run_test "Authentication: client has no cert, server required (SSLv3)" \
1799 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
1800 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
1801 key_file=data_files/server5.key" \
1802 1 \
1803 -S "skip write certificate request" \
1804 -C "skip parse certificate request" \
1805 -c "got a certificate request" \
1806 -c "got no certificate to send" \
1807 -S "x509_verify_cert() returned" \
1808 -s "client has no certificate" \
1809 -s "! mbedtls_ssl_handshake returned" \
1810 -c "! mbedtls_ssl_handshake returned" \
1811 -s "No client certification received from the client, but required by the authentication mode"
1812
1813run_test "Authentication: client has no cert, server required (TLS)" \
1814 "$P_SRV debug_level=3 auth_mode=required" \
1815 "$P_CLI debug_level=3 crt_file=none \
1816 key_file=data_files/server5.key" \
1817 1 \
1818 -S "skip write certificate request" \
1819 -C "skip parse certificate request" \
1820 -c "got a certificate request" \
1821 -c "= write certificate$" \
1822 -C "skip write certificate$" \
1823 -S "x509_verify_cert() returned" \
1824 -s "client has no certificate" \
1825 -s "! mbedtls_ssl_handshake returned" \
1826 -c "! mbedtls_ssl_handshake returned" \
1827 -s "No client certification received from the client, but required by the authentication mode"
1828
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001829run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001830 "$P_SRV debug_level=3 auth_mode=required" \
1831 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001832 key_file=data_files/server5.key" \
1833 1 \
1834 -S "skip write certificate request" \
1835 -C "skip parse certificate request" \
1836 -c "got a certificate request" \
1837 -C "skip write certificate" \
1838 -C "skip write certificate verify" \
1839 -S "skip parse certificate verify" \
1840 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001841 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001842 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02001843 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001844 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001845 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02001846# We don't check that the client receives the alert because it might
1847# detect that its write end of the connection is closed and abort
1848# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001849
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001850run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001851 "$P_SRV debug_level=3 auth_mode=optional" \
1852 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001853 key_file=data_files/server5.key" \
1854 0 \
1855 -S "skip write certificate request" \
1856 -C "skip parse certificate request" \
1857 -c "got a certificate request" \
1858 -C "skip write certificate" \
1859 -C "skip write certificate verify" \
1860 -S "skip parse certificate verify" \
1861 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001862 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001863 -S "! mbedtls_ssl_handshake returned" \
1864 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001865 -S "X509 - Certificate verification failed"
1866
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001867run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001868 "$P_SRV debug_level=3 auth_mode=none" \
1869 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001870 key_file=data_files/server5.key" \
1871 0 \
1872 -s "skip write certificate request" \
1873 -C "skip parse certificate request" \
1874 -c "got no certificate request" \
1875 -c "skip write certificate" \
1876 -c "skip write certificate verify" \
1877 -s "skip parse certificate verify" \
1878 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001879 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001880 -S "! mbedtls_ssl_handshake returned" \
1881 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001882 -S "X509 - Certificate verification failed"
1883
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001884run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001885 "$P_SRV debug_level=3 auth_mode=optional" \
1886 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001887 0 \
1888 -S "skip write certificate request" \
1889 -C "skip parse certificate request" \
1890 -c "got a certificate request" \
1891 -C "skip write certificate$" \
1892 -C "got no certificate to send" \
1893 -S "SSLv3 client has no certificate" \
1894 -c "skip write certificate verify" \
1895 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001896 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001897 -S "! mbedtls_ssl_handshake returned" \
1898 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001899 -S "X509 - Certificate verification failed"
1900
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001901run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001902 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001903 "$O_CLI" \
1904 0 \
1905 -S "skip write certificate request" \
1906 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001907 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001908 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001909 -S "X509 - Certificate verification failed"
1910
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001911run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001912 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001913 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001914 0 \
1915 -C "skip parse certificate request" \
1916 -c "got a certificate request" \
1917 -C "skip write certificate$" \
1918 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001919 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001920
Gilles Peskinefd8332e2017-05-03 16:25:07 +02001921run_test "Authentication: client no cert, openssl server required" \
1922 "$O_SRV -Verify 10" \
1923 "$P_CLI debug_level=3 crt_file=none key_file=none" \
1924 1 \
1925 -C "skip parse certificate request" \
1926 -c "got a certificate request" \
1927 -C "skip write certificate$" \
1928 -c "skip write certificate verify" \
1929 -c "! mbedtls_ssl_handshake returned"
1930
Janos Follathe2681a42016-03-07 15:57:05 +00001931requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001932run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001933 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001934 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001935 0 \
1936 -S "skip write certificate request" \
1937 -C "skip parse certificate request" \
1938 -c "got a certificate request" \
1939 -C "skip write certificate$" \
1940 -c "skip write certificate verify" \
1941 -c "got no certificate to send" \
1942 -s "SSLv3 client has no certificate" \
1943 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001944 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001945 -S "! mbedtls_ssl_handshake returned" \
1946 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001947 -S "X509 - Certificate verification failed"
1948
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001949# Tests for certificate selection based on SHA verson
1950
1951run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1952 "$P_SRV crt_file=data_files/server5.crt \
1953 key_file=data_files/server5.key \
1954 crt_file2=data_files/server5-sha1.crt \
1955 key_file2=data_files/server5.key" \
1956 "$P_CLI force_version=tls1_2" \
1957 0 \
1958 -c "signed using.*ECDSA with SHA256" \
1959 -C "signed using.*ECDSA with SHA1"
1960
1961run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1962 "$P_SRV crt_file=data_files/server5.crt \
1963 key_file=data_files/server5.key \
1964 crt_file2=data_files/server5-sha1.crt \
1965 key_file2=data_files/server5.key" \
1966 "$P_CLI force_version=tls1_1" \
1967 0 \
1968 -C "signed using.*ECDSA with SHA256" \
1969 -c "signed using.*ECDSA with SHA1"
1970
1971run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1972 "$P_SRV crt_file=data_files/server5.crt \
1973 key_file=data_files/server5.key \
1974 crt_file2=data_files/server5-sha1.crt \
1975 key_file2=data_files/server5.key" \
1976 "$P_CLI force_version=tls1" \
1977 0 \
1978 -C "signed using.*ECDSA with SHA256" \
1979 -c "signed using.*ECDSA with SHA1"
1980
1981run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1982 "$P_SRV crt_file=data_files/server5.crt \
1983 key_file=data_files/server5.key \
1984 crt_file2=data_files/server6.crt \
1985 key_file2=data_files/server6.key" \
1986 "$P_CLI force_version=tls1_1" \
1987 0 \
1988 -c "serial number.*09" \
1989 -c "signed using.*ECDSA with SHA256" \
1990 -C "signed using.*ECDSA with SHA1"
1991
1992run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1993 "$P_SRV crt_file=data_files/server6.crt \
1994 key_file=data_files/server6.key \
1995 crt_file2=data_files/server5.crt \
1996 key_file2=data_files/server5.key" \
1997 "$P_CLI force_version=tls1_1" \
1998 0 \
1999 -c "serial number.*0A" \
2000 -c "signed using.*ECDSA with SHA256" \
2001 -C "signed using.*ECDSA with SHA1"
2002
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002003# tests for SNI
2004
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002005run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002006 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002007 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002008 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002009 0 \
2010 -S "parse ServerName extension" \
2011 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2012 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002014run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002015 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002016 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002017 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 +02002018 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002019 0 \
2020 -s "parse ServerName extension" \
2021 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2022 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002024run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002025 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002026 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002027 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 +02002028 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002029 0 \
2030 -s "parse ServerName extension" \
2031 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2032 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002033
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002034run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002035 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002036 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002037 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 +02002038 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002039 1 \
2040 -s "parse ServerName extension" \
2041 -s "ssl_sni_wrapper() returned" \
2042 -s "mbedtls_ssl_handshake returned" \
2043 -c "mbedtls_ssl_handshake returned" \
2044 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002045
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002046run_test "SNI: client auth no override: optional" \
2047 "$P_SRV debug_level=3 auth_mode=optional \
2048 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2049 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2050 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002051 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002052 -S "skip write certificate request" \
2053 -C "skip parse certificate request" \
2054 -c "got a certificate request" \
2055 -C "skip write certificate" \
2056 -C "skip write certificate verify" \
2057 -S "skip parse certificate verify"
2058
2059run_test "SNI: client auth override: none -> optional" \
2060 "$P_SRV debug_level=3 auth_mode=none \
2061 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2062 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2063 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002064 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002065 -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
2072run_test "SNI: client auth override: optional -> none" \
2073 "$P_SRV debug_level=3 auth_mode=optional \
2074 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2075 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2076 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002077 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002078 -s "skip write certificate request" \
2079 -C "skip parse certificate request" \
2080 -c "got no certificate request" \
2081 -c "skip write certificate" \
2082 -c "skip write certificate verify" \
2083 -s "skip parse certificate verify"
2084
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002085run_test "SNI: CA no override" \
2086 "$P_SRV debug_level=3 auth_mode=optional \
2087 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2088 ca_file=data_files/test-ca.crt \
2089 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2090 "$P_CLI debug_level=3 server_name=localhost \
2091 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2092 1 \
2093 -S "skip write certificate request" \
2094 -C "skip parse certificate request" \
2095 -c "got a certificate request" \
2096 -C "skip write certificate" \
2097 -C "skip write certificate verify" \
2098 -S "skip parse certificate verify" \
2099 -s "x509_verify_cert() returned" \
2100 -s "! The certificate is not correctly signed by the trusted CA" \
2101 -S "The certificate has been revoked (is on a CRL)"
2102
2103run_test "SNI: CA override" \
2104 "$P_SRV debug_level=3 auth_mode=optional \
2105 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2106 ca_file=data_files/test-ca.crt \
2107 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2108 "$P_CLI debug_level=3 server_name=localhost \
2109 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2110 0 \
2111 -S "skip write certificate request" \
2112 -C "skip parse certificate request" \
2113 -c "got a certificate request" \
2114 -C "skip write certificate" \
2115 -C "skip write certificate verify" \
2116 -S "skip parse certificate verify" \
2117 -S "x509_verify_cert() returned" \
2118 -S "! The certificate is not correctly signed by the trusted CA" \
2119 -S "The certificate has been revoked (is on a CRL)"
2120
2121run_test "SNI: CA override with CRL" \
2122 "$P_SRV debug_level=3 auth_mode=optional \
2123 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2124 ca_file=data_files/test-ca.crt \
2125 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2126 "$P_CLI debug_level=3 server_name=localhost \
2127 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2128 1 \
2129 -S "skip write certificate request" \
2130 -C "skip parse certificate request" \
2131 -c "got a certificate request" \
2132 -C "skip write certificate" \
2133 -C "skip write certificate verify" \
2134 -S "skip parse certificate verify" \
2135 -s "x509_verify_cert() returned" \
2136 -S "! The certificate is not correctly signed by the trusted CA" \
2137 -s "The certificate has been revoked (is on a CRL)"
2138
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002139# Tests for non-blocking I/O: exercise a variety of handshake flows
2140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002141run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002142 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2143 "$P_CLI nbio=2 tickets=0" \
2144 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002145 -S "mbedtls_ssl_handshake returned" \
2146 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002147 -c "Read from server: .* bytes read"
2148
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002149run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002150 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2151 "$P_CLI nbio=2 tickets=0" \
2152 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002153 -S "mbedtls_ssl_handshake returned" \
2154 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002155 -c "Read from server: .* bytes read"
2156
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002157run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002158 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2159 "$P_CLI nbio=2 tickets=1" \
2160 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002161 -S "mbedtls_ssl_handshake returned" \
2162 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002163 -c "Read from server: .* bytes read"
2164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002165run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002166 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2167 "$P_CLI nbio=2 tickets=1" \
2168 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002169 -S "mbedtls_ssl_handshake returned" \
2170 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002171 -c "Read from server: .* bytes read"
2172
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002173run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002174 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2175 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2176 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002177 -S "mbedtls_ssl_handshake returned" \
2178 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002179 -c "Read from server: .* bytes read"
2180
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002181run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002182 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2183 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2184 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002185 -S "mbedtls_ssl_handshake returned" \
2186 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002187 -c "Read from server: .* bytes read"
2188
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002189run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002190 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2191 "$P_CLI nbio=2 tickets=0 reconnect=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é-Gonnard0b6609b2014-02-26 14:45:12 +01002195 -c "Read from server: .* bytes read"
2196
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002197# Tests for version negotiation
2198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002199run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002200 "$P_SRV" \
2201 "$P_CLI" \
2202 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002203 -S "mbedtls_ssl_handshake returned" \
2204 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002205 -s "Protocol is TLSv1.2" \
2206 -c "Protocol is TLSv1.2"
2207
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002208run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002209 "$P_SRV" \
2210 "$P_CLI max_version=tls1_1" \
2211 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002212 -S "mbedtls_ssl_handshake returned" \
2213 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002214 -s "Protocol is TLSv1.1" \
2215 -c "Protocol is TLSv1.1"
2216
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002217run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002218 "$P_SRV max_version=tls1_1" \
2219 "$P_CLI" \
2220 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002221 -S "mbedtls_ssl_handshake returned" \
2222 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002223 -s "Protocol is TLSv1.1" \
2224 -c "Protocol is TLSv1.1"
2225
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002226run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002227 "$P_SRV max_version=tls1_1" \
2228 "$P_CLI max_version=tls1_1" \
2229 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002230 -S "mbedtls_ssl_handshake returned" \
2231 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002232 -s "Protocol is TLSv1.1" \
2233 -c "Protocol is TLSv1.1"
2234
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002235run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002236 "$P_SRV min_version=tls1_1" \
2237 "$P_CLI max_version=tls1_1" \
2238 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002239 -S "mbedtls_ssl_handshake returned" \
2240 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002241 -s "Protocol is TLSv1.1" \
2242 -c "Protocol is TLSv1.1"
2243
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002244run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002245 "$P_SRV max_version=tls1_1" \
2246 "$P_CLI min_version=tls1_1" \
2247 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002248 -S "mbedtls_ssl_handshake returned" \
2249 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002250 -s "Protocol is TLSv1.1" \
2251 -c "Protocol is TLSv1.1"
2252
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002253run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002254 "$P_SRV max_version=tls1_1" \
2255 "$P_CLI min_version=tls1_2" \
2256 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002257 -s "mbedtls_ssl_handshake returned" \
2258 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002259 -c "SSL - Handshake protocol not within min/max boundaries"
2260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002261run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002262 "$P_SRV min_version=tls1_2" \
2263 "$P_CLI max_version=tls1_1" \
2264 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002265 -s "mbedtls_ssl_handshake returned" \
2266 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002267 -s "SSL - Handshake protocol not within min/max boundaries"
2268
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002269# Tests for ALPN extension
2270
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002271run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002272 "$P_SRV debug_level=3" \
2273 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002274 0 \
2275 -C "client hello, adding alpn extension" \
2276 -S "found alpn extension" \
2277 -C "got an alert message, type: \\[2:120]" \
2278 -S "server hello, adding alpn extension" \
2279 -C "found alpn extension " \
2280 -C "Application Layer Protocol is" \
2281 -S "Application Layer Protocol is"
2282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002283run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002284 "$P_SRV debug_level=3" \
2285 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002286 0 \
2287 -c "client hello, adding alpn extension" \
2288 -s "found alpn extension" \
2289 -C "got an alert message, type: \\[2:120]" \
2290 -S "server hello, adding alpn extension" \
2291 -C "found alpn extension " \
2292 -c "Application Layer Protocol is (none)" \
2293 -S "Application Layer Protocol is"
2294
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002295run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002296 "$P_SRV debug_level=3 alpn=abc,1234" \
2297 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002298 0 \
2299 -C "client hello, adding alpn extension" \
2300 -S "found alpn extension" \
2301 -C "got an alert message, type: \\[2:120]" \
2302 -S "server hello, adding alpn extension" \
2303 -C "found alpn extension " \
2304 -C "Application Layer Protocol is" \
2305 -s "Application Layer Protocol is (none)"
2306
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002307run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002308 "$P_SRV debug_level=3 alpn=abc,1234" \
2309 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002310 0 \
2311 -c "client hello, adding alpn extension" \
2312 -s "found alpn extension" \
2313 -C "got an alert message, type: \\[2:120]" \
2314 -s "server hello, adding alpn extension" \
2315 -c "found alpn extension" \
2316 -c "Application Layer Protocol is abc" \
2317 -s "Application Layer Protocol is abc"
2318
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002319run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002320 "$P_SRV debug_level=3 alpn=abc,1234" \
2321 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002322 0 \
2323 -c "client hello, adding alpn extension" \
2324 -s "found alpn extension" \
2325 -C "got an alert message, type: \\[2:120]" \
2326 -s "server hello, adding alpn extension" \
2327 -c "found alpn extension" \
2328 -c "Application Layer Protocol is abc" \
2329 -s "Application Layer Protocol is abc"
2330
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002331run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002332 "$P_SRV debug_level=3 alpn=abc,1234" \
2333 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002334 0 \
2335 -c "client hello, adding alpn extension" \
2336 -s "found alpn extension" \
2337 -C "got an alert message, type: \\[2:120]" \
2338 -s "server hello, adding alpn extension" \
2339 -c "found alpn extension" \
2340 -c "Application Layer Protocol is 1234" \
2341 -s "Application Layer Protocol is 1234"
2342
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002343run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002344 "$P_SRV debug_level=3 alpn=abc,123" \
2345 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002346 1 \
2347 -c "client hello, adding alpn extension" \
2348 -s "found alpn extension" \
2349 -c "got an alert message, type: \\[2:120]" \
2350 -S "server hello, adding alpn extension" \
2351 -C "found alpn extension" \
2352 -C "Application Layer Protocol is 1234" \
2353 -S "Application Layer Protocol is 1234"
2354
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002355
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002356# Tests for keyUsage in leaf certificates, part 1:
2357# server-side certificate/suite selection
2358
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002359run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002360 "$P_SRV key_file=data_files/server2.key \
2361 crt_file=data_files/server2.ku-ds.crt" \
2362 "$P_CLI" \
2363 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002364 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002365
2366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002367run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002368 "$P_SRV key_file=data_files/server2.key \
2369 crt_file=data_files/server2.ku-ke.crt" \
2370 "$P_CLI" \
2371 0 \
2372 -c "Ciphersuite is TLS-RSA-WITH-"
2373
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002374run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002375 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002376 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002377 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002378 1 \
2379 -C "Ciphersuite is "
2380
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002381run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002382 "$P_SRV key_file=data_files/server5.key \
2383 crt_file=data_files/server5.ku-ds.crt" \
2384 "$P_CLI" \
2385 0 \
2386 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2387
2388
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002389run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002390 "$P_SRV key_file=data_files/server5.key \
2391 crt_file=data_files/server5.ku-ka.crt" \
2392 "$P_CLI" \
2393 0 \
2394 -c "Ciphersuite is TLS-ECDH-"
2395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002396run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002397 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002398 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002399 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002400 1 \
2401 -C "Ciphersuite is "
2402
2403# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002404# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002405
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002406run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002407 "$O_SRV -key data_files/server2.key \
2408 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002409 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002410 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2411 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002412 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002413 -C "Processing of the Certificate handshake message failed" \
2414 -c "Ciphersuite is TLS-"
2415
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002416run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002417 "$O_SRV -key data_files/server2.key \
2418 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002419 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002420 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2421 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002422 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002423 -C "Processing of the Certificate handshake message failed" \
2424 -c "Ciphersuite is TLS-"
2425
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002426run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002427 "$O_SRV -key data_files/server2.key \
2428 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002429 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002430 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2431 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002432 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002433 -C "Processing of the Certificate handshake message failed" \
2434 -c "Ciphersuite is TLS-"
2435
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002436run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002437 "$O_SRV -key data_files/server2.key \
2438 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002439 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002440 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2441 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002442 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002443 -c "Processing of the Certificate handshake message failed" \
2444 -C "Ciphersuite is TLS-"
2445
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002446run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2447 "$O_SRV -key data_files/server2.key \
2448 -cert data_files/server2.ku-ke.crt" \
2449 "$P_CLI debug_level=1 auth_mode=optional \
2450 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2451 0 \
2452 -c "bad certificate (usage extensions)" \
2453 -C "Processing of the Certificate handshake message failed" \
2454 -c "Ciphersuite is TLS-" \
2455 -c "! Usage does not match the keyUsage extension"
2456
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002457run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002458 "$O_SRV -key data_files/server2.key \
2459 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002460 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002461 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2462 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002463 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002464 -C "Processing of the Certificate handshake message failed" \
2465 -c "Ciphersuite is TLS-"
2466
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002467run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002468 "$O_SRV -key data_files/server2.key \
2469 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002470 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002471 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2472 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002473 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002474 -c "Processing of the Certificate handshake message failed" \
2475 -C "Ciphersuite is TLS-"
2476
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002477run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2478 "$O_SRV -key data_files/server2.key \
2479 -cert data_files/server2.ku-ds.crt" \
2480 "$P_CLI debug_level=1 auth_mode=optional \
2481 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2482 0 \
2483 -c "bad certificate (usage extensions)" \
2484 -C "Processing of the Certificate handshake message failed" \
2485 -c "Ciphersuite is TLS-" \
2486 -c "! Usage does not match the keyUsage extension"
2487
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002488# Tests for keyUsage in leaf certificates, part 3:
2489# server-side checking of client cert
2490
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002491run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002492 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002493 "$O_CLI -key data_files/server2.key \
2494 -cert data_files/server2.ku-ds.crt" \
2495 0 \
2496 -S "bad certificate (usage extensions)" \
2497 -S "Processing of the Certificate handshake message failed"
2498
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002499run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002500 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002501 "$O_CLI -key data_files/server2.key \
2502 -cert data_files/server2.ku-ke.crt" \
2503 0 \
2504 -s "bad certificate (usage extensions)" \
2505 -S "Processing of the Certificate handshake message failed"
2506
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002507run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002508 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002509 "$O_CLI -key data_files/server2.key \
2510 -cert data_files/server2.ku-ke.crt" \
2511 1 \
2512 -s "bad certificate (usage extensions)" \
2513 -s "Processing of the Certificate handshake message failed"
2514
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002515run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002516 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002517 "$O_CLI -key data_files/server5.key \
2518 -cert data_files/server5.ku-ds.crt" \
2519 0 \
2520 -S "bad certificate (usage extensions)" \
2521 -S "Processing of the Certificate handshake message failed"
2522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002523run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002524 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002525 "$O_CLI -key data_files/server5.key \
2526 -cert data_files/server5.ku-ka.crt" \
2527 0 \
2528 -s "bad certificate (usage extensions)" \
2529 -S "Processing of the Certificate handshake message failed"
2530
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002531# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2532
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002533run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002534 "$P_SRV key_file=data_files/server5.key \
2535 crt_file=data_files/server5.eku-srv.crt" \
2536 "$P_CLI" \
2537 0
2538
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002539run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002540 "$P_SRV key_file=data_files/server5.key \
2541 crt_file=data_files/server5.eku-srv.crt" \
2542 "$P_CLI" \
2543 0
2544
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002545run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002546 "$P_SRV key_file=data_files/server5.key \
2547 crt_file=data_files/server5.eku-cs_any.crt" \
2548 "$P_CLI" \
2549 0
2550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002551run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002552 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002553 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002554 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002555 1
2556
2557# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002559run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002560 "$O_SRV -key data_files/server5.key \
2561 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002562 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002563 0 \
2564 -C "bad certificate (usage extensions)" \
2565 -C "Processing of the Certificate handshake message failed" \
2566 -c "Ciphersuite is TLS-"
2567
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002568run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002569 "$O_SRV -key data_files/server5.key \
2570 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002571 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002572 0 \
2573 -C "bad certificate (usage extensions)" \
2574 -C "Processing of the Certificate handshake message failed" \
2575 -c "Ciphersuite is TLS-"
2576
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002577run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002578 "$O_SRV -key data_files/server5.key \
2579 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002580 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002581 0 \
2582 -C "bad certificate (usage extensions)" \
2583 -C "Processing of the Certificate handshake message failed" \
2584 -c "Ciphersuite is TLS-"
2585
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002586run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002587 "$O_SRV -key data_files/server5.key \
2588 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002589 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002590 1 \
2591 -c "bad certificate (usage extensions)" \
2592 -c "Processing of the Certificate handshake message failed" \
2593 -C "Ciphersuite is TLS-"
2594
2595# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002597run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002598 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002599 "$O_CLI -key data_files/server5.key \
2600 -cert data_files/server5.eku-cli.crt" \
2601 0 \
2602 -S "bad certificate (usage extensions)" \
2603 -S "Processing of the Certificate handshake message failed"
2604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002605run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002606 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002607 "$O_CLI -key data_files/server5.key \
2608 -cert data_files/server5.eku-srv_cli.crt" \
2609 0 \
2610 -S "bad certificate (usage extensions)" \
2611 -S "Processing of the Certificate handshake message failed"
2612
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002613run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002614 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002615 "$O_CLI -key data_files/server5.key \
2616 -cert data_files/server5.eku-cs_any.crt" \
2617 0 \
2618 -S "bad certificate (usage extensions)" \
2619 -S "Processing of the Certificate handshake message failed"
2620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002621run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002622 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002623 "$O_CLI -key data_files/server5.key \
2624 -cert data_files/server5.eku-cs.crt" \
2625 0 \
2626 -s "bad certificate (usage extensions)" \
2627 -S "Processing of the Certificate handshake message failed"
2628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002629run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002630 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002631 "$O_CLI -key data_files/server5.key \
2632 -cert data_files/server5.eku-cs.crt" \
2633 1 \
2634 -s "bad certificate (usage extensions)" \
2635 -s "Processing of the Certificate handshake message failed"
2636
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002637# Tests for DHM parameters loading
2638
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002639run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002640 "$P_SRV" \
2641 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2642 debug_level=3" \
2643 0 \
2644 -c "value of 'DHM: P ' (2048 bits)" \
2645 -c "value of 'DHM: G ' (2048 bits)"
2646
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002647run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002648 "$P_SRV dhm_file=data_files/dhparams.pem" \
2649 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2650 debug_level=3" \
2651 0 \
2652 -c "value of 'DHM: P ' (1024 bits)" \
2653 -c "value of 'DHM: G ' (2 bits)"
2654
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002655# Tests for DHM client-side size checking
2656
2657run_test "DHM size: server default, client default, OK" \
2658 "$P_SRV" \
2659 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2660 debug_level=1" \
2661 0 \
2662 -C "DHM prime too short:"
2663
2664run_test "DHM size: server default, client 2048, OK" \
2665 "$P_SRV" \
2666 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2667 debug_level=1 dhmlen=2048" \
2668 0 \
2669 -C "DHM prime too short:"
2670
2671run_test "DHM size: server 1024, client default, OK" \
2672 "$P_SRV dhm_file=data_files/dhparams.pem" \
2673 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2674 debug_level=1" \
2675 0 \
2676 -C "DHM prime too short:"
2677
2678run_test "DHM size: server 1000, client default, rejected" \
2679 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2680 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2681 debug_level=1" \
2682 1 \
2683 -c "DHM prime too short:"
2684
2685run_test "DHM size: server default, client 2049, rejected" \
2686 "$P_SRV" \
2687 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2688 debug_level=1 dhmlen=2049" \
2689 1 \
2690 -c "DHM prime too short:"
2691
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002692# Tests for PSK callback
2693
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002694run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002695 "$P_SRV psk=abc123 psk_identity=foo" \
2696 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2697 psk_identity=foo psk=abc123" \
2698 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002699 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002700 -S "SSL - Unknown identity received" \
2701 -S "SSL - Verification of the message MAC failed"
2702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002703run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002704 "$P_SRV" \
2705 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2706 psk_identity=foo psk=abc123" \
2707 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002708 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002709 -S "SSL - Unknown identity received" \
2710 -S "SSL - Verification of the message MAC failed"
2711
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002712run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002713 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2714 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2715 psk_identity=foo psk=abc123" \
2716 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002717 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002718 -s "SSL - Unknown identity received" \
2719 -S "SSL - Verification of the message MAC failed"
2720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002721run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002722 "$P_SRV psk_list=abc,dead,def,beef" \
2723 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2724 psk_identity=abc psk=dead" \
2725 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002726 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002727 -S "SSL - Unknown identity received" \
2728 -S "SSL - Verification of the message MAC failed"
2729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002730run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002731 "$P_SRV psk_list=abc,dead,def,beef" \
2732 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2733 psk_identity=def psk=beef" \
2734 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002735 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002736 -S "SSL - Unknown identity received" \
2737 -S "SSL - Verification of the message MAC failed"
2738
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002739run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002740 "$P_SRV psk_list=abc,dead,def,beef" \
2741 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2742 psk_identity=ghi psk=beef" \
2743 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002744 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002745 -s "SSL - Unknown identity received" \
2746 -S "SSL - Verification of the message MAC failed"
2747
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002748run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002749 "$P_SRV psk_list=abc,dead,def,beef" \
2750 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2751 psk_identity=abc psk=beef" \
2752 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002753 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002754 -S "SSL - Unknown identity received" \
2755 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002756
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002757# Tests for EC J-PAKE
2758
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002759requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002760run_test "ECJPAKE: client not configured" \
2761 "$P_SRV debug_level=3" \
2762 "$P_CLI debug_level=3" \
2763 0 \
2764 -C "add ciphersuite: c0ff" \
2765 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002766 -S "found ecjpake kkpp extension" \
2767 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002768 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002769 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002770 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002771 -S "None of the common ciphersuites is usable"
2772
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002773requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002774run_test "ECJPAKE: server not configured" \
2775 "$P_SRV debug_level=3" \
2776 "$P_CLI debug_level=3 ecjpake_pw=bla \
2777 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2778 1 \
2779 -c "add ciphersuite: c0ff" \
2780 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002781 -s "found ecjpake kkpp extension" \
2782 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002783 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002784 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002785 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002786 -s "None of the common ciphersuites is usable"
2787
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002788requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002789run_test "ECJPAKE: working, TLS" \
2790 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2791 "$P_CLI debug_level=3 ecjpake_pw=bla \
2792 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002793 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002794 -c "add ciphersuite: c0ff" \
2795 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002796 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002797 -s "found ecjpake kkpp extension" \
2798 -S "skip ecjpake kkpp extension" \
2799 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002800 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002801 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002802 -S "None of the common ciphersuites is usable" \
2803 -S "SSL - Verification of the message MAC failed"
2804
Janos Follath74537a62016-09-02 13:45:28 +01002805server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002806requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002807run_test "ECJPAKE: password mismatch, TLS" \
2808 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2809 "$P_CLI debug_level=3 ecjpake_pw=bad \
2810 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2811 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002812 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002813 -s "SSL - Verification of the message MAC failed"
2814
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002815requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002816run_test "ECJPAKE: working, DTLS" \
2817 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2818 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2819 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2820 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002821 -c "re-using cached ecjpake parameters" \
2822 -S "SSL - Verification of the message MAC failed"
2823
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002824requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002825run_test "ECJPAKE: working, DTLS, no cookie" \
2826 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2827 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2828 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2829 0 \
2830 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002831 -S "SSL - Verification of the message MAC failed"
2832
Janos Follath74537a62016-09-02 13:45:28 +01002833server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002834requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002835run_test "ECJPAKE: password mismatch, DTLS" \
2836 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2837 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2838 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2839 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002840 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002841 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002842
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002843# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002844requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002845run_test "ECJPAKE: working, DTLS, nolog" \
2846 "$P_SRV dtls=1 ecjpake_pw=bla" \
2847 "$P_CLI dtls=1 ecjpake_pw=bla \
2848 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2849 0
2850
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002851# Tests for ciphersuites per version
2852
Janos Follathe2681a42016-03-07 15:57:05 +00002853requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002854run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002855 "$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 +02002856 "$P_CLI force_version=ssl3" \
2857 0 \
2858 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2859
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002860run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002861 "$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 +01002862 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002863 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002864 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002866run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002867 "$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 +02002868 "$P_CLI force_version=tls1_1" \
2869 0 \
2870 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2871
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002872run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002873 "$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 +02002874 "$P_CLI force_version=tls1_2" \
2875 0 \
2876 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2877
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002878# Test for ClientHello without extensions
2879
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002880requires_gnutls
2881run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002882 "$P_SRV debug_level=3" \
2883 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2884 0 \
2885 -s "dumping 'client hello extensions' (0 bytes)"
2886
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002887# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002888
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002889run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002890 "$P_SRV" \
2891 "$P_CLI request_size=100" \
2892 0 \
2893 -s "Read from client: 100 bytes read$"
2894
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002895run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002896 "$P_SRV" \
2897 "$P_CLI request_size=500" \
2898 0 \
2899 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002900
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002901# Tests for small packets
2902
Janos Follathe2681a42016-03-07 15:57:05 +00002903requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002904run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002905 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002906 "$P_CLI request_size=1 force_version=ssl3 \
2907 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2908 0 \
2909 -s "Read from client: 1 bytes read"
2910
Janos Follathe2681a42016-03-07 15:57:05 +00002911requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002912run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002913 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002914 "$P_CLI request_size=1 force_version=ssl3 \
2915 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2916 0 \
2917 -s "Read from client: 1 bytes read"
2918
2919run_test "Small packet TLS 1.0 BlockCipher" \
2920 "$P_SRV" \
2921 "$P_CLI request_size=1 force_version=tls1 \
2922 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2923 0 \
2924 -s "Read from client: 1 bytes read"
2925
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002926run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2927 "$P_SRV" \
2928 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2929 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2930 0 \
2931 -s "Read from client: 1 bytes read"
2932
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002933run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2934 "$P_SRV" \
2935 "$P_CLI request_size=1 force_version=tls1 \
2936 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2937 trunc_hmac=1" \
2938 0 \
2939 -s "Read from client: 1 bytes read"
2940
2941run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002942 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002943 "$P_CLI request_size=1 force_version=tls1 \
2944 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2945 trunc_hmac=1" \
2946 0 \
2947 -s "Read from client: 1 bytes read"
2948
2949run_test "Small packet TLS 1.1 BlockCipher" \
2950 "$P_SRV" \
2951 "$P_CLI request_size=1 force_version=tls1_1 \
2952 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2953 0 \
2954 -s "Read from client: 1 bytes read"
2955
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002956run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2957 "$P_SRV" \
2958 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2959 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2960 0 \
2961 -s "Read from client: 1 bytes read"
2962
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002963run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002964 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002965 "$P_CLI request_size=1 force_version=tls1_1 \
2966 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2967 0 \
2968 -s "Read from client: 1 bytes read"
2969
2970run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2971 "$P_SRV" \
2972 "$P_CLI request_size=1 force_version=tls1_1 \
2973 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2974 trunc_hmac=1" \
2975 0 \
2976 -s "Read from client: 1 bytes read"
2977
2978run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002979 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002980 "$P_CLI request_size=1 force_version=tls1_1 \
2981 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2982 trunc_hmac=1" \
2983 0 \
2984 -s "Read from client: 1 bytes read"
2985
2986run_test "Small packet TLS 1.2 BlockCipher" \
2987 "$P_SRV" \
2988 "$P_CLI request_size=1 force_version=tls1_2 \
2989 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2990 0 \
2991 -s "Read from client: 1 bytes read"
2992
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002993run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2994 "$P_SRV" \
2995 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2996 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2997 0 \
2998 -s "Read from client: 1 bytes read"
2999
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003000run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3001 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003002 "$P_CLI request_size=1 force_version=tls1_2 \
3003 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003004 0 \
3005 -s "Read from client: 1 bytes read"
3006
3007run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3008 "$P_SRV" \
3009 "$P_CLI request_size=1 force_version=tls1_2 \
3010 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3011 trunc_hmac=1" \
3012 0 \
3013 -s "Read from client: 1 bytes read"
3014
3015run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003016 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003017 "$P_CLI request_size=1 force_version=tls1_2 \
3018 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3019 0 \
3020 -s "Read from client: 1 bytes read"
3021
3022run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003023 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003024 "$P_CLI request_size=1 force_version=tls1_2 \
3025 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3026 trunc_hmac=1" \
3027 0 \
3028 -s "Read from client: 1 bytes read"
3029
3030run_test "Small packet TLS 1.2 AEAD" \
3031 "$P_SRV" \
3032 "$P_CLI request_size=1 force_version=tls1_2 \
3033 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3034 0 \
3035 -s "Read from client: 1 bytes read"
3036
3037run_test "Small packet TLS 1.2 AEAD shorter tag" \
3038 "$P_SRV" \
3039 "$P_CLI request_size=1 force_version=tls1_2 \
3040 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3041 0 \
3042 -s "Read from client: 1 bytes read"
3043
Janos Follath00efff72016-05-06 13:48:23 +01003044# A test for extensions in SSLv3
3045
3046requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3047run_test "SSLv3 with extensions, server side" \
3048 "$P_SRV min_version=ssl3 debug_level=3" \
3049 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3050 0 \
3051 -S "dumping 'client hello extensions'" \
3052 -S "server hello, total extension length:"
3053
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003054# Test for large packets
3055
Janos Follathe2681a42016-03-07 15:57:05 +00003056requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003057run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003058 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003059 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003060 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3061 0 \
3062 -s "Read from client: 16384 bytes read"
3063
Janos Follathe2681a42016-03-07 15:57:05 +00003064requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003065run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003066 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003067 "$P_CLI request_size=16384 force_version=ssl3 \
3068 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3069 0 \
3070 -s "Read from client: 16384 bytes read"
3071
3072run_test "Large packet TLS 1.0 BlockCipher" \
3073 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003074 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003075 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3076 0 \
3077 -s "Read from client: 16384 bytes read"
3078
3079run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3080 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003081 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003082 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3083 trunc_hmac=1" \
3084 0 \
3085 -s "Read from client: 16384 bytes read"
3086
3087run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003088 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003089 "$P_CLI request_size=16384 force_version=tls1 \
3090 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3091 trunc_hmac=1" \
3092 0 \
3093 -s "Read from client: 16384 bytes read"
3094
3095run_test "Large packet TLS 1.1 BlockCipher" \
3096 "$P_SRV" \
3097 "$P_CLI request_size=16384 force_version=tls1_1 \
3098 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3099 0 \
3100 -s "Read from client: 16384 bytes read"
3101
3102run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003103 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003104 "$P_CLI request_size=16384 force_version=tls1_1 \
3105 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3106 0 \
3107 -s "Read from client: 16384 bytes read"
3108
3109run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3110 "$P_SRV" \
3111 "$P_CLI request_size=16384 force_version=tls1_1 \
3112 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3113 trunc_hmac=1" \
3114 0 \
3115 -s "Read from client: 16384 bytes read"
3116
3117run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003118 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003119 "$P_CLI request_size=16384 force_version=tls1_1 \
3120 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3121 trunc_hmac=1" \
3122 0 \
3123 -s "Read from client: 16384 bytes read"
3124
3125run_test "Large packet TLS 1.2 BlockCipher" \
3126 "$P_SRV" \
3127 "$P_CLI request_size=16384 force_version=tls1_2 \
3128 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3129 0 \
3130 -s "Read from client: 16384 bytes read"
3131
3132run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3133 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003134 "$P_CLI request_size=16384 force_version=tls1_2 \
3135 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003136 0 \
3137 -s "Read from client: 16384 bytes read"
3138
3139run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3140 "$P_SRV" \
3141 "$P_CLI request_size=16384 force_version=tls1_2 \
3142 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3143 trunc_hmac=1" \
3144 0 \
3145 -s "Read from client: 16384 bytes read"
3146
3147run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003148 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003149 "$P_CLI request_size=16384 force_version=tls1_2 \
3150 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3151 0 \
3152 -s "Read from client: 16384 bytes read"
3153
3154run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003155 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003156 "$P_CLI request_size=16384 force_version=tls1_2 \
3157 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3158 trunc_hmac=1" \
3159 0 \
3160 -s "Read from client: 16384 bytes read"
3161
3162run_test "Large packet TLS 1.2 AEAD" \
3163 "$P_SRV" \
3164 "$P_CLI request_size=16384 force_version=tls1_2 \
3165 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3166 0 \
3167 -s "Read from client: 16384 bytes read"
3168
3169run_test "Large packet TLS 1.2 AEAD shorter tag" \
3170 "$P_SRV" \
3171 "$P_CLI request_size=16384 force_version=tls1_2 \
3172 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3173 0 \
3174 -s "Read from client: 16384 bytes read"
3175
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003176# Tests for DTLS HelloVerifyRequest
3177
3178run_test "DTLS cookie: enabled" \
3179 "$P_SRV dtls=1 debug_level=2" \
3180 "$P_CLI dtls=1 debug_level=2" \
3181 0 \
3182 -s "cookie verification failed" \
3183 -s "cookie verification passed" \
3184 -S "cookie verification skipped" \
3185 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003186 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003187 -S "SSL - The requested feature is not available"
3188
3189run_test "DTLS cookie: disabled" \
3190 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3191 "$P_CLI dtls=1 debug_level=2" \
3192 0 \
3193 -S "cookie verification failed" \
3194 -S "cookie verification passed" \
3195 -s "cookie verification skipped" \
3196 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003197 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003198 -S "SSL - The requested feature is not available"
3199
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003200run_test "DTLS cookie: default (failing)" \
3201 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3202 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3203 1 \
3204 -s "cookie verification failed" \
3205 -S "cookie verification passed" \
3206 -S "cookie verification skipped" \
3207 -C "received hello verify request" \
3208 -S "hello verification requested" \
3209 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003210
3211requires_ipv6
3212run_test "DTLS cookie: enabled, IPv6" \
3213 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3214 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3215 0 \
3216 -s "cookie verification failed" \
3217 -s "cookie verification passed" \
3218 -S "cookie verification skipped" \
3219 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003220 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003221 -S "SSL - The requested feature is not available"
3222
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003223run_test "DTLS cookie: enabled, nbio" \
3224 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3225 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3226 0 \
3227 -s "cookie verification failed" \
3228 -s "cookie verification passed" \
3229 -S "cookie verification skipped" \
3230 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003231 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003232 -S "SSL - The requested feature is not available"
3233
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003234# Tests for client reconnecting from the same port with DTLS
3235
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003236not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003237run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003238 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3239 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003240 0 \
3241 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003242 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003243 -S "Client initiated reconnection from same port"
3244
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003245not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003246run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003247 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3248 "$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 +02003249 0 \
3250 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003251 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003252 -s "Client initiated reconnection from same port"
3253
Paul Bakker362689d2016-05-13 10:33:25 +01003254not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3255run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003256 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3257 "$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 +02003258 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003259 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003260 -s "Client initiated reconnection from same port"
3261
Paul Bakker362689d2016-05-13 10:33:25 +01003262only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3263run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3264 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3265 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3266 0 \
3267 -S "The operation timed out" \
3268 -s "Client initiated reconnection from same port"
3269
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003270run_test "DTLS client reconnect from same port: no cookies" \
3271 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003272 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3273 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003274 -s "The operation timed out" \
3275 -S "Client initiated reconnection from same port"
3276
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003277# Tests for various cases of client authentication with DTLS
3278# (focused on handshake flows and message parsing)
3279
3280run_test "DTLS client auth: required" \
3281 "$P_SRV dtls=1 auth_mode=required" \
3282 "$P_CLI dtls=1" \
3283 0 \
3284 -s "Verifying peer X.509 certificate... ok"
3285
3286run_test "DTLS client auth: optional, client has no cert" \
3287 "$P_SRV dtls=1 auth_mode=optional" \
3288 "$P_CLI dtls=1 crt_file=none key_file=none" \
3289 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003290 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003291
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003292run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003293 "$P_SRV dtls=1 auth_mode=none" \
3294 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3295 0 \
3296 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003297 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003298
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003299run_test "DTLS wrong PSK: badmac alert" \
3300 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3301 "$P_CLI dtls=1 psk=abc124" \
3302 1 \
3303 -s "SSL - Verification of the message MAC failed" \
3304 -c "SSL - A fatal alert message was received from our peer"
3305
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003306# Tests for receiving fragmented handshake messages with DTLS
3307
3308requires_gnutls
3309run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3310 "$G_SRV -u --mtu 2048 -a" \
3311 "$P_CLI dtls=1 debug_level=2" \
3312 0 \
3313 -C "found fragmented DTLS handshake message" \
3314 -C "error"
3315
3316requires_gnutls
3317run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3318 "$G_SRV -u --mtu 512" \
3319 "$P_CLI dtls=1 debug_level=2" \
3320 0 \
3321 -c "found fragmented DTLS handshake message" \
3322 -C "error"
3323
3324requires_gnutls
3325run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3326 "$G_SRV -u --mtu 128" \
3327 "$P_CLI dtls=1 debug_level=2" \
3328 0 \
3329 -c "found fragmented DTLS handshake message" \
3330 -C "error"
3331
3332requires_gnutls
3333run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3334 "$G_SRV -u --mtu 128" \
3335 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3336 0 \
3337 -c "found fragmented DTLS handshake message" \
3338 -C "error"
3339
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003340requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003341run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3342 "$G_SRV -u --mtu 256" \
3343 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3344 0 \
3345 -c "found fragmented DTLS handshake message" \
3346 -c "client hello, adding renegotiation extension" \
3347 -c "found renegotiation extension" \
3348 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003349 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003350 -C "error" \
3351 -s "Extra-header:"
3352
3353requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003354run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3355 "$G_SRV -u --mtu 256" \
3356 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3357 0 \
3358 -c "found fragmented DTLS handshake message" \
3359 -c "client hello, adding renegotiation extension" \
3360 -c "found renegotiation extension" \
3361 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003362 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003363 -C "error" \
3364 -s "Extra-header:"
3365
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003366run_test "DTLS reassembly: no fragmentation (openssl server)" \
3367 "$O_SRV -dtls1 -mtu 2048" \
3368 "$P_CLI dtls=1 debug_level=2" \
3369 0 \
3370 -C "found fragmented DTLS handshake message" \
3371 -C "error"
3372
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003373run_test "DTLS reassembly: some fragmentation (openssl server)" \
3374 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003375 "$P_CLI dtls=1 debug_level=2" \
3376 0 \
3377 -c "found fragmented DTLS handshake message" \
3378 -C "error"
3379
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003380run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003381 "$O_SRV -dtls1 -mtu 256" \
3382 "$P_CLI dtls=1 debug_level=2" \
3383 0 \
3384 -c "found fragmented DTLS handshake message" \
3385 -C "error"
3386
3387run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3388 "$O_SRV -dtls1 -mtu 256" \
3389 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3390 0 \
3391 -c "found fragmented DTLS handshake message" \
3392 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003393
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003394# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003395
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003396not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003397run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003398 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003399 "$P_SRV dtls=1 debug_level=2" \
3400 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003401 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003402 -C "replayed record" \
3403 -S "replayed record" \
3404 -C "record from another epoch" \
3405 -S "record from another epoch" \
3406 -C "discarding invalid record" \
3407 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003408 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003409 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003410 -c "HTTP/1.0 200 OK"
3411
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003412not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003413run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003414 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003415 "$P_SRV dtls=1 debug_level=2" \
3416 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003417 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003418 -c "replayed record" \
3419 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003420 -c "discarding invalid record" \
3421 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003422 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003423 -s "Extra-header:" \
3424 -c "HTTP/1.0 200 OK"
3425
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003426run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3427 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003428 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3429 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003430 0 \
3431 -c "replayed record" \
3432 -S "replayed record" \
3433 -c "discarding invalid record" \
3434 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003435 -c "resend" \
3436 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003437 -s "Extra-header:" \
3438 -c "HTTP/1.0 200 OK"
3439
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003440run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003441 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003442 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003443 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003444 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003445 -c "discarding invalid record (mac)" \
3446 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003447 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003448 -c "HTTP/1.0 200 OK" \
3449 -S "too many records with bad MAC" \
3450 -S "Verification of the message MAC failed"
3451
3452run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3453 -p "$P_PXY bad_ad=1" \
3454 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3455 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3456 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003457 -C "discarding invalid record (mac)" \
3458 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003459 -S "Extra-header:" \
3460 -C "HTTP/1.0 200 OK" \
3461 -s "too many records with bad MAC" \
3462 -s "Verification of the message MAC failed"
3463
3464run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3465 -p "$P_PXY bad_ad=1" \
3466 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3467 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3468 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003469 -c "discarding invalid record (mac)" \
3470 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003471 -s "Extra-header:" \
3472 -c "HTTP/1.0 200 OK" \
3473 -S "too many records with bad MAC" \
3474 -S "Verification of the message MAC failed"
3475
3476run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3477 -p "$P_PXY bad_ad=1" \
3478 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3479 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3480 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003481 -c "discarding invalid record (mac)" \
3482 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003483 -s "Extra-header:" \
3484 -c "HTTP/1.0 200 OK" \
3485 -s "too many records with bad MAC" \
3486 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003487
3488run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003489 -p "$P_PXY delay_ccs=1" \
3490 "$P_SRV dtls=1 debug_level=1" \
3491 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003492 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003493 -c "record from another epoch" \
3494 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003495 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003496 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003497 -s "Extra-header:" \
3498 -c "HTTP/1.0 200 OK"
3499
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003500# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003501
Janos Follath74537a62016-09-02 13:45:28 +01003502client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003503run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003504 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003505 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3506 psk=abc123" \
3507 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003508 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3509 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é-Gonnard18e519a2014-09-24 19:09:17 +02003514run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
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 tickets=0 auth_mode=none" \
3517 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003518 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3519 0 \
3520 -s "Extra-header:" \
3521 -c "HTTP/1.0 200 OK"
3522
Janos Follath74537a62016-09-02 13:45:28 +01003523client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003524run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3525 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003526 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3527 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003528 0 \
3529 -s "Extra-header:" \
3530 -c "HTTP/1.0 200 OK"
3531
Janos Follath74537a62016-09-02 13:45:28 +01003532client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003533run_test "DTLS proxy: 3d, FS, client auth" \
3534 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003535 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3536 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003537 0 \
3538 -s "Extra-header:" \
3539 -c "HTTP/1.0 200 OK"
3540
Janos Follath74537a62016-09-02 13:45:28 +01003541client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003542run_test "DTLS proxy: 3d, FS, ticket" \
3543 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003544 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3545 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003546 0 \
3547 -s "Extra-header:" \
3548 -c "HTTP/1.0 200 OK"
3549
Janos Follath74537a62016-09-02 13:45:28 +01003550client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003551run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3552 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003553 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3554 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003555 0 \
3556 -s "Extra-header:" \
3557 -c "HTTP/1.0 200 OK"
3558
Janos Follath74537a62016-09-02 13:45:28 +01003559client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003560run_test "DTLS proxy: 3d, max handshake, nbio" \
3561 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003562 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3563 auth_mode=required" \
3564 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003565 0 \
3566 -s "Extra-header:" \
3567 -c "HTTP/1.0 200 OK"
3568
Janos Follath74537a62016-09-02 13:45:28 +01003569client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003570run_test "DTLS proxy: 3d, min handshake, resumption" \
3571 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3572 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3573 psk=abc123 debug_level=3" \
3574 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3575 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3576 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3577 0 \
3578 -s "a session has been resumed" \
3579 -c "a session has been resumed" \
3580 -s "Extra-header:" \
3581 -c "HTTP/1.0 200 OK"
3582
Janos Follath74537a62016-09-02 13:45:28 +01003583client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003584run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3585 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3586 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3587 psk=abc123 debug_level=3 nbio=2" \
3588 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3589 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3590 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3591 0 \
3592 -s "a session has been resumed" \
3593 -c "a session has been resumed" \
3594 -s "Extra-header:" \
3595 -c "HTTP/1.0 200 OK"
3596
Janos Follath74537a62016-09-02 13:45:28 +01003597client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003598run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003599 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003600 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3601 psk=abc123 renegotiation=1 debug_level=2" \
3602 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3603 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003604 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3605 0 \
3606 -c "=> renegotiate" \
3607 -s "=> renegotiate" \
3608 -s "Extra-header:" \
3609 -c "HTTP/1.0 200 OK"
3610
Janos Follath74537a62016-09-02 13:45:28 +01003611client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003612run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3613 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003614 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3615 psk=abc123 renegotiation=1 debug_level=2" \
3616 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3617 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003618 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3619 0 \
3620 -c "=> renegotiate" \
3621 -s "=> renegotiate" \
3622 -s "Extra-header:" \
3623 -c "HTTP/1.0 200 OK"
3624
Janos Follath74537a62016-09-02 13:45:28 +01003625client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003626run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003627 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003628 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003629 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003630 debug_level=2" \
3631 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003632 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003633 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3634 0 \
3635 -c "=> renegotiate" \
3636 -s "=> renegotiate" \
3637 -s "Extra-header:" \
3638 -c "HTTP/1.0 200 OK"
3639
Janos Follath74537a62016-09-02 13:45:28 +01003640client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003641run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003642 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003643 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003644 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003645 debug_level=2 nbio=2" \
3646 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003647 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003648 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3649 0 \
3650 -c "=> renegotiate" \
3651 -s "=> renegotiate" \
3652 -s "Extra-header:" \
3653 -c "HTTP/1.0 200 OK"
3654
Janos Follath74537a62016-09-02 13:45:28 +01003655client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003656not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003657run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003658 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3659 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003660 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003661 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003662 -c "HTTP/1.0 200 OK"
3663
Janos Follath74537a62016-09-02 13:45:28 +01003664client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003665not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003666run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3667 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3668 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003669 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003670 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003671 -c "HTTP/1.0 200 OK"
3672
Janos Follath74537a62016-09-02 13:45:28 +01003673client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003674not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003675run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3676 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3677 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003678 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003679 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003680 -c "HTTP/1.0 200 OK"
3681
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003682requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003683client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003684not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003685run_test "DTLS proxy: 3d, gnutls server" \
3686 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3687 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003688 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003689 0 \
3690 -s "Extra-header:" \
3691 -c "Extra-header:"
3692
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003693requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003694client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003695not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003696run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3697 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3698 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003699 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003700 0 \
3701 -s "Extra-header:" \
3702 -c "Extra-header:"
3703
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003704requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003705client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003706not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003707run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3708 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3709 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003710 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003711 0 \
3712 -s "Extra-header:" \
3713 -c "Extra-header:"
3714
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003715# Final report
3716
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003717echo "------------------------------------------------------------------------"
3718
3719if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003720 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003721else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003722 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003723fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003724PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003725echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003726
3727exit $FAILS