2014-08-31 10:22:11 +02:00
|
|
|
#!/bin/sh
|
2013-07-19 13:41:51 +02:00
|
|
|
|
2016-09-04 23:31:09 +02:00
|
|
|
# compat.sh
|
|
|
|
#
|
2020-08-07 13:07:28 +02:00
|
|
|
# Copyright The Mbed TLS Contributors
|
2020-05-26 01:54:15 +02:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
2016-09-04 23:31:09 +02:00
|
|
|
# Purpose
|
|
|
|
#
|
|
|
|
# Test interoperbility with OpenSSL, GnuTLS as well as itself.
|
2014-03-25 19:07:28 +01:00
|
|
|
#
|
|
|
|
# Check each common ciphersuite, with each version, both ways (client/server),
|
|
|
|
# with and without client authentication.
|
2014-02-20 11:01:30 +01:00
|
|
|
|
2014-03-28 10:12:38 +01:00
|
|
|
set -u
|
|
|
|
|
2019-07-03 14:51:04 +02:00
|
|
|
# Limit the size of each log to 10 GiB, in case of failures with this script
|
|
|
|
# where it may output seemingly unlimited length error logs.
|
|
|
|
ulimit -f 20971520
|
|
|
|
|
2023-02-20 07:58:03 +01:00
|
|
|
ORIGINAL_PWD=$PWD
|
|
|
|
if ! cd "$(dirname "$0")"; then
|
|
|
|
exit 125
|
|
|
|
fi
|
|
|
|
|
2014-03-25 18:04:59 +01:00
|
|
|
# initialise counters
|
2014-08-31 10:22:11 +02:00
|
|
|
TESTS=0
|
|
|
|
FAILED=0
|
|
|
|
SKIPPED=0
|
|
|
|
SRVMEM=0
|
2013-08-27 22:00:47 +02:00
|
|
|
|
2019-01-23 15:24:37 +01:00
|
|
|
# default commands, can be overridden by the environment
|
2016-09-04 23:31:09 +02:00
|
|
|
: ${M_SRV:=../programs/ssl/ssl_server2}
|
|
|
|
: ${M_CLI:=../programs/ssl/ssl_client2}
|
2023-01-10 09:38:58 +01:00
|
|
|
: ${OPENSSL:=openssl}
|
2014-03-13 18:47:44 +01:00
|
|
|
: ${GNUTLS_CLI:=gnutls-cli}
|
|
|
|
: ${GNUTLS_SERV:=gnutls-serv}
|
2014-02-27 12:25:54 +01:00
|
|
|
|
Use OPENSSL everywhere, not OPENSSL_CMD
These variables were both uses to select the default version of OpenSSL
to use for tests:
- when running compat.sh or ssl-opt.sh directly, OPENSSL_CMD was used;
- when running all.sh, OPENSSL was used.
This caused surprising situations if you had one but not the other set
in your environment. For example I used to have OPENSSL_CMD set but not
OPENSSL, so ssl-opt.sh was failing in some all.sh components but passing
when I ran it manually in the same configuration and build, a rather
unpleasant experience.
The natural name would be OPENSSL, and that's what set in the Docker
images used by the CI. However back in the 1.3.x days, that name was
already used in library/Makefile, so it was preferable to pick a
different one, hence OPENSSL_CMD. However the build system has not been
using this name since at least Mbed TLS 2.0.0, so it's now free for use
again (as demonstrated by the fact that it's been set in the CI without
causing any trouble).
So, unify things and use OPENSSL everywhere. Just leave an error message
for the benefit of developers which might have OPENSSL_CMD, not OPENSSL,
set in their environment from the old days.
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-12-19 11:42:12 +01:00
|
|
|
# The OPENSSL variable used to be OPENSSL_CMD for historical reasons.
|
|
|
|
# To help the migration, error out if the old variable is set,
|
|
|
|
# but only if it has a different value than the new one.
|
|
|
|
if [ "${OPENSSL_CMD+set}" = set ]; then
|
|
|
|
# the variable is set, we can now check its value
|
|
|
|
if [ "$OPENSSL_CMD" != "$OPENSSL" ]; then
|
|
|
|
echo "Please use OPENSSL instead of OPENSSL_CMD." >&2
|
|
|
|
exit 125
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2014-08-31 16:20:58 +02:00
|
|
|
# do we have a recent enough GnuTLS?
|
2015-06-26 15:45:30 +02:00
|
|
|
if ( which $GNUTLS_CLI && which $GNUTLS_SERV ) >/dev/null 2>&1; then
|
2014-10-24 12:57:37 +02:00
|
|
|
G_VER="$( $GNUTLS_CLI --version | head -n1 )"
|
|
|
|
if echo "$G_VER" | grep '@VERSION@' > /dev/null; then # git version
|
2014-08-31 16:20:58 +02:00
|
|
|
PEER_GNUTLS=" GnuTLS"
|
2014-10-24 12:57:37 +02:00
|
|
|
else
|
|
|
|
eval $( echo $G_VER | sed 's/.* \([0-9]*\)\.\([0-9]\)*\.\([0-9]*\)$/MAJOR="\1" MINOR="\2" PATCH="\3"/' )
|
|
|
|
if [ $MAJOR -lt 3 -o \
|
|
|
|
\( $MAJOR -eq 3 -a $MINOR -lt 2 \) -o \
|
|
|
|
\( $MAJOR -eq 3 -a $MINOR -eq 2 -a $PATCH -lt 15 \) ]
|
|
|
|
then
|
|
|
|
PEER_GNUTLS=""
|
|
|
|
else
|
|
|
|
PEER_GNUTLS=" GnuTLS"
|
2018-06-14 13:14:29 +02:00
|
|
|
if [ $MINOR -lt 4 ]; then
|
|
|
|
GNUTLS_MINOR_LT_FOUR='x'
|
|
|
|
fi
|
2014-10-24 12:57:37 +02:00
|
|
|
fi
|
2014-08-31 16:20:58 +02:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
PEER_GNUTLS=""
|
|
|
|
fi
|
|
|
|
|
2023-02-20 07:58:03 +01:00
|
|
|
guess_config_name() {
|
|
|
|
if git diff --quiet ../include/mbedtls/mbedtls_config.h 2>/dev/null; then
|
|
|
|
echo "default"
|
|
|
|
else
|
|
|
|
echo "unknown"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
: ${MBEDTLS_TEST_OUTCOME_FILE=}
|
|
|
|
: ${MBEDTLS_TEST_CONFIGURATION:="$(guess_config_name)"}
|
|
|
|
: ${MBEDTLS_TEST_PLATFORM:="$(uname -s | tr -c \\n0-9A-Za-z _)-$(uname -m | tr -c \\n0-9A-Za-z _)"}
|
|
|
|
|
2014-03-25 18:04:59 +01:00
|
|
|
# default values for options
|
2022-04-14 09:21:56 +02:00
|
|
|
# /!\ keep this synchronised with:
|
|
|
|
# - basic-build-test.sh
|
|
|
|
# - all.sh (multiple components)
|
2021-12-02 09:43:35 +01:00
|
|
|
MODES="tls12 dtls12"
|
2012-11-23 14:25:34 +01:00
|
|
|
VERIFIES="NO YES"
|
2013-08-27 21:03:33 +02:00
|
|
|
TYPES="ECDSA RSA PSK"
|
2013-07-19 13:41:51 +02:00
|
|
|
FILTER=""
|
2022-04-14 09:21:56 +02:00
|
|
|
# By default, exclude:
|
|
|
|
# - NULL: excluded from our default config + requires OpenSSL legacy
|
2022-04-06 13:21:59 +02:00
|
|
|
# - ARIA: requires OpenSSL >= 1.1.1
|
2018-06-18 11:38:22 +02:00
|
|
|
# - ChachaPoly: requires OpenSSL >= 1.1.0
|
2023-01-13 11:00:10 +01:00
|
|
|
EXCLUDE='NULL\|ARIA\|CHACHA20_POLY1305'
|
2013-07-19 13:41:51 +02:00
|
|
|
VERBOSE=""
|
2014-02-27 15:37:24 +01:00
|
|
|
MEMCHECK=0
|
2015-01-22 17:43:54 +01:00
|
|
|
PEERS="OpenSSL$PEER_GNUTLS mbedTLS"
|
2013-07-19 13:41:51 +02:00
|
|
|
|
2015-08-04 16:43:37 +02:00
|
|
|
# hidden option: skip DTLS with OpenSSL
|
|
|
|
# (travis CI has a version that doesn't work for us)
|
|
|
|
: ${OSSL_NO_DTLS:=0}
|
|
|
|
|
2014-02-26 18:21:02 +01:00
|
|
|
print_usage() {
|
|
|
|
echo "Usage: $0"
|
2014-12-11 11:51:28 +01:00
|
|
|
printf " -h|--help\tPrint this help.\n"
|
2020-08-26 20:05:11 +02:00
|
|
|
printf " -f|--filter\tOnly matching ciphersuites are tested (Default: '%s')\n" "$FILTER"
|
|
|
|
printf " -e|--exclude\tMatching ciphersuites are excluded (Default: '%s')\n" "$EXCLUDE"
|
|
|
|
printf " -m|--modes\tWhich modes to perform (Default: '%s')\n" "$MODES"
|
|
|
|
printf " -t|--types\tWhich key exchange type to perform (Default: '%s')\n" "$TYPES"
|
|
|
|
printf " -V|--verify\tWhich verification modes to perform (Default: '%s')\n" "$VERIFIES"
|
|
|
|
printf " -p|--peers\tWhich peers to use (Default: '%s')\n" "$PEERS"
|
2014-12-11 11:51:28 +01:00
|
|
|
printf " \tAlso available: GnuTLS (needs v3.2.15 or higher)\n"
|
|
|
|
printf " -M|--memcheck\tCheck memory leaks and errors.\n"
|
|
|
|
printf " -v|--verbose\tSet verbose output.\n"
|
2023-02-20 07:58:03 +01:00
|
|
|
printf " --outcome-file\tFile where test outcomes are written\n"
|
|
|
|
printf " \t(default: \$MBEDTLS_TEST_OUTCOME_FILE, none if empty)\n"
|
2014-02-26 18:21:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
get_options() {
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case "$1" in
|
|
|
|
-f|--filter)
|
|
|
|
shift; FILTER=$1
|
|
|
|
;;
|
2014-03-13 17:45:35 +01:00
|
|
|
-e|--exclude)
|
|
|
|
shift; EXCLUDE=$1
|
|
|
|
;;
|
2014-02-26 18:21:02 +01:00
|
|
|
-m|--modes)
|
|
|
|
shift; MODES=$1
|
|
|
|
;;
|
|
|
|
-t|--types)
|
|
|
|
shift; TYPES=$1
|
|
|
|
;;
|
|
|
|
-V|--verify)
|
|
|
|
shift; VERIFIES=$1
|
|
|
|
;;
|
2014-03-13 17:45:35 +01:00
|
|
|
-p|--peers)
|
|
|
|
shift; PEERS=$1
|
|
|
|
;;
|
2014-02-26 18:21:02 +01:00
|
|
|
-v|--verbose)
|
|
|
|
VERBOSE=1
|
|
|
|
;;
|
2014-02-27 15:37:24 +01:00
|
|
|
-M|--memcheck)
|
|
|
|
MEMCHECK=1
|
|
|
|
;;
|
2023-02-20 07:58:03 +01:00
|
|
|
--outcome-file)
|
|
|
|
shift; MBEDTLS_TEST_OUTCOME_FILE=$1
|
|
|
|
;;
|
2014-02-26 18:21:02 +01:00
|
|
|
-h|--help)
|
|
|
|
print_usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown argument: '$1'"
|
|
|
|
print_usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2014-10-24 12:47:26 +02:00
|
|
|
|
|
|
|
# sanitize some options (modes checked later)
|
|
|
|
VERIFIES="$( echo $VERIFIES | tr [a-z] [A-Z] )"
|
|
|
|
TYPES="$( echo $TYPES | tr [a-z] [A-Z] )"
|
2014-02-26 18:21:02 +01:00
|
|
|
}
|
2013-07-19 13:41:51 +02:00
|
|
|
|
2014-02-19 15:29:38 +01:00
|
|
|
log() {
|
2013-07-19 13:41:51 +02:00
|
|
|
if [ "X" != "X$VERBOSE" ]; then
|
2014-03-26 15:30:16 +01:00
|
|
|
echo ""
|
2013-07-19 13:41:51 +02:00
|
|
|
echo "$@"
|
|
|
|
fi
|
|
|
|
}
|
2012-04-12 23:26:34 +02:00
|
|
|
|
2014-03-26 15:30:16 +01:00
|
|
|
# is_dtls <mode>
|
|
|
|
is_dtls()
|
|
|
|
{
|
2021-12-02 09:43:35 +01:00
|
|
|
test "$1" = "dtls12"
|
2014-03-26 15:30:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# minor_ver <mode>
|
|
|
|
minor_ver()
|
|
|
|
{
|
|
|
|
case "$1" in
|
2021-12-02 09:43:35 +01:00
|
|
|
tls12|dtls12)
|
2014-03-26 15:30:16 +01:00
|
|
|
echo 3
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "error: invalid mode: $MODE" >&2
|
|
|
|
# exiting is no good here, typically called in a subshell
|
|
|
|
echo -1
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2013-08-27 20:48:40 +02:00
|
|
|
filter()
|
|
|
|
{
|
2014-03-13 17:45:35 +01:00
|
|
|
LIST="$1"
|
2013-08-27 20:48:40 +02:00
|
|
|
NEW_LIST=""
|
|
|
|
|
2021-02-22 14:36:29 +01:00
|
|
|
EXCLMODE="$EXCLUDE"
|
2014-03-26 15:30:16 +01:00
|
|
|
|
2013-08-27 20:48:40 +02:00
|
|
|
for i in $LIST;
|
|
|
|
do
|
2014-03-26 15:30:16 +01:00
|
|
|
NEW_LIST="$NEW_LIST $( echo "$i" | grep "$FILTER" | grep -v "$EXCLMODE" )"
|
2013-08-27 20:48:40 +02:00
|
|
|
done
|
|
|
|
|
2014-02-27 11:50:40 +01:00
|
|
|
# normalize whitespace
|
2014-12-11 11:51:28 +01:00
|
|
|
echo "$NEW_LIST" | sed -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ //' -e 's/ $//'
|
2013-08-27 20:48:40 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 12:42:57 +01:00
|
|
|
filter_ciphersuites()
|
|
|
|
{
|
2014-03-13 17:45:35 +01:00
|
|
|
if [ "X" != "X$FILTER" -o "X" != "X$EXCLUDE" ];
|
2014-02-28 12:42:57 +01:00
|
|
|
then
|
2016-09-04 23:31:09 +02:00
|
|
|
# Ciphersuite for mbed TLS
|
|
|
|
M_CIPHERS=$( filter "$M_CIPHERS" )
|
|
|
|
|
|
|
|
# Ciphersuite for OpenSSL
|
2014-03-13 17:45:35 +01:00
|
|
|
O_CIPHERS=$( filter "$O_CIPHERS" )
|
2016-09-04 23:31:09 +02:00
|
|
|
|
|
|
|
# Ciphersuite for GnuTLS
|
2014-03-13 17:45:35 +01:00
|
|
|
G_CIPHERS=$( filter "$G_CIPHERS" )
|
2014-02-28 12:42:57 +01:00
|
|
|
fi
|
2014-07-10 20:12:56 +02:00
|
|
|
|
2015-01-23 12:33:38 +01:00
|
|
|
# For GnuTLS client -> mbed TLS server,
|
2014-07-11 17:01:06 +02:00
|
|
|
# we need to force IPv4 by connecting to 127.0.0.1 but then auth fails
|
2023-02-08 05:38:31 +01:00
|
|
|
if is_dtls "$MODE" && [ "X$VERIFY" = "XYES" ]; then
|
2014-07-10 20:12:56 +02:00
|
|
|
G_CIPHERS=""
|
|
|
|
fi
|
2014-02-28 12:42:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
reset_ciphersuites()
|
2014-02-19 13:51:58 +01:00
|
|
|
{
|
2016-09-04 23:31:09 +02:00
|
|
|
M_CIPHERS=""
|
2014-02-19 13:51:58 +01:00
|
|
|
O_CIPHERS=""
|
2014-02-28 12:42:57 +01:00
|
|
|
G_CIPHERS=""
|
|
|
|
}
|
2014-02-19 13:51:58 +01:00
|
|
|
|
2023-01-26 21:16:34 +01:00
|
|
|
# translate_ciphers {g|m|o} {STANDARD_CIPHER_SUITE_NAME...}
|
|
|
|
# Set $ciphers to the cipher suite name translations for the specified
|
|
|
|
# program (gnutls, mbedtls or openssl). $ciphers is a space-separated
|
|
|
|
# list of entries of the form "STANDARD_NAME=PROGRAM_NAME".
|
|
|
|
translate_ciphers()
|
2021-07-29 12:35:59 +02:00
|
|
|
{
|
2023-01-26 21:16:34 +01:00
|
|
|
ciphers=$(scripts/translate_ciphers.py "$@")
|
|
|
|
if [ $? -ne 0 ]; then
|
2021-07-29 13:51:09 +02:00
|
|
|
echo "translate_ciphers.py failed with exit code $1" >&2
|
|
|
|
echo "$2" >&2
|
2021-07-29 12:35:59 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-02-15 11:43:55 +01:00
|
|
|
# Ciphersuites that can be used with all peers.
|
|
|
|
# Since we currently have three possible peers, each ciphersuite should appear
|
|
|
|
# three times: in each peer's list (with the name that this peer uses).
|
2014-03-25 19:07:28 +01:00
|
|
|
add_common_ciphersuites()
|
2014-02-28 12:42:57 +01:00
|
|
|
{
|
2021-07-27 15:55:56 +02:00
|
|
|
CIPHERS=""
|
2014-02-19 13:51:58 +01:00
|
|
|
case $TYPE in
|
|
|
|
|
|
|
|
"ECDSA")
|
2021-08-10 11:41:13 +02:00
|
|
|
CIPHERS="$CIPHERS \
|
2023-01-11 03:11:23 +01:00
|
|
|
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_NULL_SHA \
|
2021-08-10 11:41:13 +02:00
|
|
|
"
|
2014-02-19 13:51:58 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
"RSA")
|
2021-07-27 15:55:56 +02:00
|
|
|
CIPHERS="$CIPHERS \
|
2023-01-11 03:11:23 +01:00
|
|
|
TLS_DHE_RSA_WITH_AES_128_CBC_SHA \
|
|
|
|
TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 \
|
|
|
|
TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 \
|
|
|
|
TLS_DHE_RSA_WITH_AES_256_CBC_SHA \
|
|
|
|
TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 \
|
|
|
|
TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 \
|
|
|
|
TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA \
|
|
|
|
TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA \
|
|
|
|
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA \
|
|
|
|
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 \
|
|
|
|
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 \
|
|
|
|
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA \
|
|
|
|
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 \
|
|
|
|
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 \
|
|
|
|
TLS_ECDHE_RSA_WITH_NULL_SHA \
|
|
|
|
TLS_RSA_WITH_AES_128_CBC_SHA \
|
|
|
|
TLS_RSA_WITH_AES_128_CBC_SHA256 \
|
|
|
|
TLS_RSA_WITH_AES_128_GCM_SHA256 \
|
|
|
|
TLS_RSA_WITH_AES_256_CBC_SHA \
|
|
|
|
TLS_RSA_WITH_AES_256_CBC_SHA256 \
|
|
|
|
TLS_RSA_WITH_AES_256_GCM_SHA384 \
|
|
|
|
TLS_RSA_WITH_CAMELLIA_128_CBC_SHA \
|
|
|
|
TLS_RSA_WITH_CAMELLIA_256_CBC_SHA \
|
|
|
|
TLS_RSA_WITH_NULL_MD5 \
|
|
|
|
TLS_RSA_WITH_NULL_SHA \
|
|
|
|
TLS_RSA_WITH_NULL_SHA256 \
|
2014-03-25 19:07:28 +01:00
|
|
|
"
|
2014-02-19 13:51:58 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
"PSK")
|
2021-07-27 15:55:56 +02:00
|
|
|
CIPHERS="$CIPHERS \
|
2023-01-11 03:11:23 +01:00
|
|
|
TLS_PSK_WITH_AES_128_CBC_SHA \
|
|
|
|
TLS_PSK_WITH_AES_256_CBC_SHA \
|
2014-02-19 13:51:58 +01:00
|
|
|
"
|
|
|
|
;;
|
|
|
|
esac
|
2021-07-27 15:55:56 +02:00
|
|
|
|
2023-01-13 11:00:10 +01:00
|
|
|
O_CIPHERS="$O_CIPHERS $CIPHERS"
|
|
|
|
G_CIPHERS="$G_CIPHERS $CIPHERS"
|
2021-07-27 15:55:56 +02:00
|
|
|
M_CIPHERS="$M_CIPHERS $CIPHERS"
|
2014-02-19 13:51:58 +01:00
|
|
|
}
|
|
|
|
|
2018-02-15 11:43:55 +01:00
|
|
|
# Ciphersuites usable only with Mbed TLS and OpenSSL
|
2023-01-13 11:00:10 +01:00
|
|
|
# A list of ciphersuites in the standard naming convention is appended
|
|
|
|
# to the list of Mbed TLS ciphersuites $M_CIPHERS and
|
|
|
|
# to the list of OpenSSL ciphersuites $O_CIPHERS respectively.
|
|
|
|
# Based on client's naming convention, all ciphersuite names will be
|
|
|
|
# translated into another naming format before sent to the client.
|
2018-02-15 11:43:55 +01:00
|
|
|
#
|
|
|
|
# NOTE: for some reason RSA-PSK doesn't work with OpenSSL,
|
2018-03-06 09:54:10 +01:00
|
|
|
# so RSA-PSK ciphersuites need to go in other sections, see
|
2022-03-31 15:07:01 +02:00
|
|
|
# https://github.com/Mbed-TLS/mbedtls/issues/1419
|
2018-06-18 11:38:22 +02:00
|
|
|
#
|
|
|
|
# ChachaPoly suites are here rather than in "common", as they were added in
|
|
|
|
# GnuTLS in 3.5.0 and the CI only has 3.4.x so far.
|
2014-03-25 19:07:28 +01:00
|
|
|
add_openssl_ciphersuites()
|
|
|
|
{
|
2021-07-27 15:55:56 +02:00
|
|
|
CIPHERS=""
|
2014-03-25 19:07:28 +01:00
|
|
|
case $TYPE in
|
|
|
|
|
|
|
|
"ECDSA")
|
2021-08-13 14:30:36 +02:00
|
|
|
CIPHERS="$CIPHERS \
|
2023-01-11 03:11:23 +01:00
|
|
|
TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA \
|
|
|
|
TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 \
|
|
|
|
TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 \
|
|
|
|
TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA \
|
|
|
|
TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 \
|
|
|
|
TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 \
|
|
|
|
TLS_ECDH_ECDSA_WITH_NULL_SHA \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 \
|
2021-08-10 11:41:13 +02:00
|
|
|
"
|
2014-03-25 19:07:28 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
"RSA")
|
2021-08-13 14:30:36 +02:00
|
|
|
CIPHERS="$CIPHERS \
|
2023-01-11 03:11:23 +01:00
|
|
|
TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256 \
|
|
|
|
TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384 \
|
|
|
|
TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256 \
|
|
|
|
TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 \
|
|
|
|
TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 \
|
|
|
|
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 \
|
|
|
|
TLS_RSA_WITH_ARIA_128_GCM_SHA256 \
|
|
|
|
TLS_RSA_WITH_ARIA_256_GCM_SHA384 \
|
2014-03-25 19:07:28 +01:00
|
|
|
"
|
|
|
|
;;
|
|
|
|
|
|
|
|
"PSK")
|
2021-08-10 11:41:13 +02:00
|
|
|
CIPHERS="$CIPHERS \
|
2023-01-11 03:11:23 +01:00
|
|
|
TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256 \
|
|
|
|
TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384 \
|
|
|
|
TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256 \
|
|
|
|
TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 \
|
|
|
|
TLS_PSK_WITH_ARIA_128_GCM_SHA256 \
|
|
|
|
TLS_PSK_WITH_ARIA_256_GCM_SHA384 \
|
|
|
|
TLS_PSK_WITH_CHACHA20_POLY1305_SHA256 \
|
2021-08-10 11:41:13 +02:00
|
|
|
"
|
2014-03-25 19:07:28 +01:00
|
|
|
;;
|
|
|
|
esac
|
2021-07-27 15:55:56 +02:00
|
|
|
|
2023-01-13 11:00:10 +01:00
|
|
|
O_CIPHERS="$O_CIPHERS $CIPHERS"
|
2021-07-27 15:55:56 +02:00
|
|
|
M_CIPHERS="$M_CIPHERS $CIPHERS"
|
2014-03-25 19:07:28 +01:00
|
|
|
}
|
|
|
|
|
2018-02-15 11:43:55 +01:00
|
|
|
# Ciphersuites usable only with Mbed TLS and GnuTLS
|
2023-01-13 11:00:10 +01:00
|
|
|
# A list of ciphersuites in the standard naming convention is appended
|
|
|
|
# to the list of Mbed TLS ciphersuites $M_CIPHERS and
|
|
|
|
# to the list of GnuTLS ciphersuites $G_CIPHERS respectively.
|
|
|
|
# Based on client's naming convention, all ciphersuite names will be
|
|
|
|
# translated into another naming format before sent to the client.
|
2014-02-28 12:42:57 +01:00
|
|
|
add_gnutls_ciphersuites()
|
2014-02-19 13:51:58 +01:00
|
|
|
{
|
2021-07-27 15:55:56 +02:00
|
|
|
CIPHERS=""
|
2014-02-19 13:51:58 +01:00
|
|
|
case $TYPE in
|
|
|
|
|
|
|
|
"ECDSA")
|
2021-08-10 11:41:13 +02:00
|
|
|
CIPHERS="$CIPHERS \
|
2023-01-11 03:11:23 +01:00
|
|
|
TLS_ECDHE_ECDSA_WITH_AES_128_CCM \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_AES_256_CCM \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 \
|
2021-08-10 11:41:13 +02:00
|
|
|
"
|
2014-02-19 13:51:58 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
"RSA")
|
2021-08-10 11:41:13 +02:00
|
|
|
CIPHERS="$CIPHERS \
|
2023-01-11 03:11:23 +01:00
|
|
|
TLS_DHE_RSA_WITH_AES_128_CCM \
|
|
|
|
TLS_DHE_RSA_WITH_AES_128_CCM_8 \
|
|
|
|
TLS_DHE_RSA_WITH_AES_256_CCM \
|
|
|
|
TLS_DHE_RSA_WITH_AES_256_CCM_8 \
|
|
|
|
TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 \
|
|
|
|
TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 \
|
|
|
|
TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 \
|
|
|
|
TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 \
|
|
|
|
TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 \
|
|
|
|
TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 \
|
|
|
|
TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 \
|
|
|
|
TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 \
|
|
|
|
TLS_RSA_WITH_AES_128_CCM \
|
|
|
|
TLS_RSA_WITH_AES_128_CCM_8 \
|
|
|
|
TLS_RSA_WITH_AES_256_CCM \
|
|
|
|
TLS_RSA_WITH_AES_256_CCM_8 \
|
|
|
|
TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 \
|
|
|
|
TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 \
|
|
|
|
TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 \
|
|
|
|
TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 \
|
2021-08-10 11:41:13 +02:00
|
|
|
"
|
2014-02-19 13:51:58 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
"PSK")
|
2021-08-10 11:41:13 +02:00
|
|
|
CIPHERS="$CIPHERS \
|
2023-01-11 03:11:23 +01:00
|
|
|
TLS_DHE_PSK_WITH_AES_128_CBC_SHA \
|
|
|
|
TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 \
|
|
|
|
TLS_DHE_PSK_WITH_AES_128_CCM \
|
|
|
|
TLS_DHE_PSK_WITH_AES_128_CCM_8 \
|
|
|
|
TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 \
|
|
|
|
TLS_DHE_PSK_WITH_AES_256_CBC_SHA \
|
|
|
|
TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 \
|
|
|
|
TLS_DHE_PSK_WITH_AES_256_CCM \
|
|
|
|
TLS_DHE_PSK_WITH_AES_256_CCM_8 \
|
|
|
|
TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 \
|
|
|
|
TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 \
|
|
|
|
TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 \
|
|
|
|
TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 \
|
|
|
|
TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 \
|
|
|
|
TLS_DHE_PSK_WITH_NULL_SHA256 \
|
|
|
|
TLS_DHE_PSK_WITH_NULL_SHA384 \
|
|
|
|
TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA \
|
|
|
|
TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 \
|
|
|
|
TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA \
|
|
|
|
TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 \
|
|
|
|
TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 \
|
|
|
|
TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 \
|
|
|
|
TLS_ECDHE_PSK_WITH_NULL_SHA256 \
|
|
|
|
TLS_ECDHE_PSK_WITH_NULL_SHA384 \
|
|
|
|
TLS_PSK_WITH_AES_128_CBC_SHA256 \
|
|
|
|
TLS_PSK_WITH_AES_128_CCM \
|
|
|
|
TLS_PSK_WITH_AES_128_CCM_8 \
|
|
|
|
TLS_PSK_WITH_AES_128_GCM_SHA256 \
|
|
|
|
TLS_PSK_WITH_AES_256_CBC_SHA384 \
|
|
|
|
TLS_PSK_WITH_AES_256_CCM \
|
|
|
|
TLS_PSK_WITH_AES_256_CCM_8 \
|
|
|
|
TLS_PSK_WITH_AES_256_GCM_SHA384 \
|
|
|
|
TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 \
|
|
|
|
TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 \
|
|
|
|
TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 \
|
|
|
|
TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 \
|
|
|
|
TLS_PSK_WITH_NULL_SHA256 \
|
|
|
|
TLS_PSK_WITH_NULL_SHA384 \
|
|
|
|
TLS_RSA_PSK_WITH_AES_128_CBC_SHA \
|
|
|
|
TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 \
|
|
|
|
TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 \
|
|
|
|
TLS_RSA_PSK_WITH_AES_256_CBC_SHA \
|
|
|
|
TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 \
|
|
|
|
TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 \
|
|
|
|
TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 \
|
|
|
|
TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 \
|
|
|
|
TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 \
|
|
|
|
TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 \
|
|
|
|
TLS_RSA_PSK_WITH_NULL_SHA256 \
|
|
|
|
TLS_RSA_PSK_WITH_NULL_SHA384 \
|
2014-07-13 15:44:19 +02:00
|
|
|
"
|
2014-02-19 13:51:58 +01:00
|
|
|
;;
|
|
|
|
esac
|
2021-07-27 17:32:21 +02:00
|
|
|
|
2023-01-13 11:00:10 +01:00
|
|
|
G_CIPHERS="$G_CIPHERS $CIPHERS"
|
2021-07-27 15:55:56 +02:00
|
|
|
M_CIPHERS="$M_CIPHERS $CIPHERS"
|
2014-02-28 12:42:57 +01:00
|
|
|
}
|
2014-02-19 13:51:58 +01:00
|
|
|
|
2018-02-15 11:43:55 +01:00
|
|
|
# Ciphersuites usable only with Mbed TLS (not currently supported by another
|
2023-01-13 11:00:10 +01:00
|
|
|
# peer usable in this script). This provides only very rudimentaty testing, as
|
2018-02-15 11:43:55 +01:00
|
|
|
# this is not interop testing, but it's better than nothing.
|
2015-04-08 12:49:31 +02:00
|
|
|
add_mbedtls_ciphersuites()
|
2014-02-28 12:42:57 +01:00
|
|
|
{
|
|
|
|
case $TYPE in
|
|
|
|
|
|
|
|
"ECDSA")
|
2021-08-10 11:41:13 +02:00
|
|
|
M_CIPHERS="$M_CIPHERS \
|
2023-01-11 03:11:23 +01:00
|
|
|
TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256 \
|
|
|
|
TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 \
|
|
|
|
TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384 \
|
|
|
|
TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 \
|
|
|
|
TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 \
|
|
|
|
TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 \
|
|
|
|
TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 \
|
|
|
|
TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256 \
|
|
|
|
TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384 \
|
2021-08-10 11:41:13 +02:00
|
|
|
"
|
2014-02-28 12:42:57 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
"RSA")
|
2021-08-10 11:41:13 +02:00
|
|
|
M_CIPHERS="$M_CIPHERS \
|
2023-01-11 03:11:23 +01:00
|
|
|
TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256 \
|
|
|
|
TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384 \
|
|
|
|
TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256 \
|
|
|
|
TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384 \
|
|
|
|
TLS_RSA_WITH_ARIA_128_CBC_SHA256 \
|
|
|
|
TLS_RSA_WITH_ARIA_256_CBC_SHA384 \
|
2021-08-10 11:41:13 +02:00
|
|
|
"
|
2014-02-28 12:42:57 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
"PSK")
|
2023-01-11 03:11:23 +01:00
|
|
|
# *PSK_NULL_SHA suites supported by GnuTLS 3.3.5 but not 3.2.15
|
2021-08-10 11:41:13 +02:00
|
|
|
M_CIPHERS="$M_CIPHERS \
|
2023-01-11 03:11:23 +01:00
|
|
|
TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256 \
|
|
|
|
TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384 \
|
|
|
|
TLS_DHE_PSK_WITH_NULL_SHA \
|
|
|
|
TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256 \
|
|
|
|
TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384 \
|
|
|
|
TLS_ECDHE_PSK_WITH_NULL_SHA \
|
|
|
|
TLS_PSK_WITH_ARIA_128_CBC_SHA256 \
|
|
|
|
TLS_PSK_WITH_ARIA_256_CBC_SHA384 \
|
|
|
|
TLS_PSK_WITH_NULL_SHA \
|
|
|
|
TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256 \
|
|
|
|
TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256 \
|
|
|
|
TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384 \
|
|
|
|
TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384 \
|
|
|
|
TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256 \
|
|
|
|
TLS_RSA_PSK_WITH_NULL_SHA \
|
2014-02-28 12:42:57 +01:00
|
|
|
"
|
|
|
|
;;
|
|
|
|
esac
|
2014-02-19 13:51:58 +01:00
|
|
|
}
|
|
|
|
|
2023-02-20 11:05:21 +01:00
|
|
|
# o_check_ciphersuite STANDARD_CIPHER_SUITE
|
|
|
|
o_check_ciphersuite()
|
|
|
|
{
|
2023-02-22 02:30:20 +01:00
|
|
|
if [ "${O_SUPPORT_ECDH}" = "NO" ]; then
|
|
|
|
case "$1" in
|
|
|
|
*ECDH_*) SKIP_NEXT="YES"
|
|
|
|
esac
|
2023-02-20 11:05:21 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-02-19 13:35:52 +01:00
|
|
|
setup_arguments()
|
|
|
|
{
|
2022-03-11 17:15:23 +01:00
|
|
|
O_MODE=""
|
2014-03-26 15:30:16 +01:00
|
|
|
G_MODE=""
|
|
|
|
case "$MODE" in
|
2021-12-02 09:43:35 +01:00
|
|
|
"tls12")
|
2022-03-11 17:15:23 +01:00
|
|
|
O_MODE="tls1_2"
|
2014-02-28 12:42:57 +01:00
|
|
|
G_PRIO_MODE="+VERS-TLS1.2"
|
2014-02-19 14:24:24 +01:00
|
|
|
;;
|
2021-12-02 09:43:35 +01:00
|
|
|
"dtls12")
|
2022-03-11 17:15:23 +01:00
|
|
|
O_MODE="dtls1_2"
|
2014-03-26 15:30:16 +01:00
|
|
|
G_PRIO_MODE="+VERS-DTLS1.2"
|
2014-09-26 16:33:45 +02:00
|
|
|
G_MODE="-u"
|
2014-03-26 15:30:16 +01:00
|
|
|
;;
|
2014-02-19 14:24:24 +01:00
|
|
|
*)
|
|
|
|
echo "error: invalid mode: $MODE" >&2
|
|
|
|
exit 1;
|
|
|
|
esac
|
|
|
|
|
2018-06-14 13:14:29 +02:00
|
|
|
# GnuTLS < 3.4 will choke if we try to allow CCM-8
|
|
|
|
if [ -z "${GNUTLS_MINOR_LT_FOUR-}" ]; then
|
|
|
|
G_PRIO_CCM="+AES-256-CCM-8:+AES-128-CCM-8:"
|
|
|
|
else
|
|
|
|
G_PRIO_CCM=""
|
|
|
|
fi
|
|
|
|
|
2021-02-22 14:36:29 +01:00
|
|
|
M_SERVER_ARGS="server_port=$PORT server_addr=0.0.0.0 force_version=$MODE"
|
2022-03-11 17:15:23 +01:00
|
|
|
O_SERVER_ARGS="-accept $PORT -cipher NULL,ALL -$O_MODE"
|
2014-03-26 15:30:16 +01:00
|
|
|
G_SERVER_ARGS="-p $PORT --http $G_MODE"
|
2021-02-22 14:36:29 +01:00
|
|
|
G_SERVER_PRIO="NORMAL:${G_PRIO_CCM}+NULL:+MD5:+PSK:+DHE-PSK:+ECDHE-PSK:+SHA256:+SHA384:+RSA-PSK:-VERS-TLS-ALL:$G_PRIO_MODE"
|
2014-02-28 12:42:57 +01:00
|
|
|
|
2021-04-01 14:00:11 +02:00
|
|
|
# The default prime for `openssl s_server` depends on the version:
|
|
|
|
# * OpenSSL <= 1.0.2a: 512-bit
|
|
|
|
# * OpenSSL 1.0.2b to 1.1.1b: 1024-bit
|
|
|
|
# * OpenSSL >= 1.1.1c: 2048-bit
|
|
|
|
# Mbed TLS wants >=1024, so force that for older versions. Don't force
|
|
|
|
# it for newer versions, which reject a 1024-bit prime. Indifferently
|
|
|
|
# force it or not for intermediate versions.
|
Use OPENSSL everywhere, not OPENSSL_CMD
These variables were both uses to select the default version of OpenSSL
to use for tests:
- when running compat.sh or ssl-opt.sh directly, OPENSSL_CMD was used;
- when running all.sh, OPENSSL was used.
This caused surprising situations if you had one but not the other set
in your environment. For example I used to have OPENSSL_CMD set but not
OPENSSL, so ssl-opt.sh was failing in some all.sh components but passing
when I ran it manually in the same configuration and build, a rather
unpleasant experience.
The natural name would be OPENSSL, and that's what set in the Docker
images used by the CI. However back in the 1.3.x days, that name was
already used in library/Makefile, so it was preferable to pick a
different one, hence OPENSSL_CMD. However the build system has not been
using this name since at least Mbed TLS 2.0.0, so it's now free for use
again (as demonstrated by the fact that it's been set in the CI without
causing any trouble).
So, unify things and use OPENSSL everywhere. Just leave an error message
for the benefit of developers which might have OPENSSL_CMD, not OPENSSL,
set in their environment from the old days.
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-12-19 11:42:12 +01:00
|
|
|
case $($OPENSSL version) in
|
2021-04-01 14:00:11 +02:00
|
|
|
"OpenSSL 1.0"*)
|
|
|
|
O_SERVER_ARGS="$O_SERVER_ARGS -dhparam data_files/dhparams.pem"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2014-07-11 17:01:06 +02:00
|
|
|
# with OpenSSL 1.0.1h, -www, -WWW and -HTTP break DTLS handshakes
|
|
|
|
if is_dtls "$MODE"; then
|
2014-09-26 16:33:45 +02:00
|
|
|
O_SERVER_ARGS="$O_SERVER_ARGS"
|
2014-07-11 17:01:06 +02:00
|
|
|
else
|
|
|
|
O_SERVER_ARGS="$O_SERVER_ARGS -www"
|
|
|
|
fi
|
|
|
|
|
2016-09-04 23:31:09 +02:00
|
|
|
M_CLIENT_ARGS="server_port=$PORT server_addr=127.0.0.1 force_version=$MODE"
|
2022-03-11 17:15:23 +01:00
|
|
|
O_CLIENT_ARGS="-connect localhost:$PORT -$O_MODE"
|
2014-03-26 15:30:16 +01:00
|
|
|
G_CLIENT_ARGS="-p $PORT --debug 3 $G_MODE"
|
2014-02-19 14:24:24 +01:00
|
|
|
|
2022-11-24 22:21:15 +01:00
|
|
|
# Newer versions of OpenSSL have a syntax to enable all "ciphers", even
|
|
|
|
# low-security ones. This covers not just cipher suites but also protocol
|
|
|
|
# versions. It is necessary, for example, to use (D)TLS 1.0/1.1 on
|
|
|
|
# OpenSSL 1.1.1f from Ubuntu 20.04. The syntax was only introduced in
|
|
|
|
# OpenSSL 1.1.0 (21e0c1d23afff48601eb93135defddae51f7e2e3) and I can't find
|
|
|
|
# a way to discover it from -help, so check the openssl version.
|
Use OPENSSL everywhere, not OPENSSL_CMD
These variables were both uses to select the default version of OpenSSL
to use for tests:
- when running compat.sh or ssl-opt.sh directly, OPENSSL_CMD was used;
- when running all.sh, OPENSSL was used.
This caused surprising situations if you had one but not the other set
in your environment. For example I used to have OPENSSL_CMD set but not
OPENSSL, so ssl-opt.sh was failing in some all.sh components but passing
when I ran it manually in the same configuration and build, a rather
unpleasant experience.
The natural name would be OPENSSL, and that's what set in the Docker
images used by the CI. However back in the 1.3.x days, that name was
already used in library/Makefile, so it was preferable to pick a
different one, hence OPENSSL_CMD. However the build system has not been
using this name since at least Mbed TLS 2.0.0, so it's now free for use
again (as demonstrated by the fact that it's been set in the CI without
causing any trouble).
So, unify things and use OPENSSL everywhere. Just leave an error message
for the benefit of developers which might have OPENSSL_CMD, not OPENSSL,
set in their environment from the old days.
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-12-19 11:42:12 +01:00
|
|
|
case $($OPENSSL version) in
|
2022-11-24 22:21:15 +01:00
|
|
|
"OpenSSL 0"*|"OpenSSL 1.0"*) :;;
|
|
|
|
*)
|
|
|
|
O_CLIENT_ARGS="$O_CLIENT_ARGS -cipher ALL@SECLEVEL=0"
|
|
|
|
O_SERVER_ARGS="$O_SERVER_ARGS -cipher ALL@SECLEVEL=0"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2023-02-20 11:05:21 +01:00
|
|
|
case $($OPENSSL ciphers ALL) in
|
2023-02-23 08:24:47 +01:00
|
|
|
*ECDH-ECDSA*|*ECDH-RSA*) O_SUPPORT_ECDH="YES";;
|
2023-02-22 02:30:20 +01:00
|
|
|
*) O_SUPPORT_ECDH="NO";;
|
2023-02-20 11:05:21 +01:00
|
|
|
esac
|
|
|
|
|
2023-02-08 05:38:31 +01:00
|
|
|
if [ "X$VERIFY" = "XYES" ];
|
2014-02-19 13:35:52 +01:00
|
|
|
then
|
2016-09-04 23:31:09 +02:00
|
|
|
M_SERVER_ARGS="$M_SERVER_ARGS ca_file=data_files/test-ca_cat12.crt auth_mode=required"
|
2014-02-19 14:24:24 +01:00
|
|
|
O_SERVER_ARGS="$O_SERVER_ARGS -CAfile data_files/test-ca_cat12.crt -Verify 10"
|
2014-02-28 12:42:57 +01:00
|
|
|
G_SERVER_ARGS="$G_SERVER_ARGS --x509cafile data_files/test-ca_cat12.crt --require-client-cert"
|
|
|
|
|
2016-09-04 23:31:09 +02:00
|
|
|
M_CLIENT_ARGS="$M_CLIENT_ARGS ca_file=data_files/test-ca_cat12.crt auth_mode=required"
|
2014-02-21 10:10:20 +01:00
|
|
|
O_CLIENT_ARGS="$O_CLIENT_ARGS -CAfile data_files/test-ca_cat12.crt -verify 10"
|
2014-03-13 16:21:59 +01:00
|
|
|
G_CLIENT_ARGS="$G_CLIENT_ARGS --x509cafile data_files/test-ca_cat12.crt"
|
2014-02-21 10:10:20 +01:00
|
|
|
else
|
2014-02-28 12:42:57 +01:00
|
|
|
# don't request a client cert at all
|
2016-09-04 23:31:09 +02:00
|
|
|
M_SERVER_ARGS="$M_SERVER_ARGS ca_file=none auth_mode=none"
|
2014-02-28 12:42:57 +01:00
|
|
|
G_SERVER_ARGS="$G_SERVER_ARGS --disable-client-cert"
|
|
|
|
|
2016-09-04 23:31:09 +02:00
|
|
|
M_CLIENT_ARGS="$M_CLIENT_ARGS ca_file=none auth_mode=none"
|
2014-03-19 17:34:52 +01:00
|
|
|
O_CLIENT_ARGS="$O_CLIENT_ARGS"
|
|
|
|
G_CLIENT_ARGS="$G_CLIENT_ARGS --insecure"
|
2014-02-19 13:35:52 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
case $TYPE in
|
|
|
|
"ECDSA")
|
2016-09-04 23:31:09 +02:00
|
|
|
M_SERVER_ARGS="$M_SERVER_ARGS crt_file=data_files/server5.crt key_file=data_files/server5.key"
|
2014-02-19 14:24:24 +01:00
|
|
|
O_SERVER_ARGS="$O_SERVER_ARGS -cert data_files/server5.crt -key data_files/server5.key"
|
2014-02-28 12:42:57 +01:00
|
|
|
G_SERVER_ARGS="$G_SERVER_ARGS --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
|
|
|
|
|
2014-02-27 14:38:29 +01:00
|
|
|
if [ "X$VERIFY" = "XYES" ]; then
|
2016-09-04 23:31:09 +02:00
|
|
|
M_CLIENT_ARGS="$M_CLIENT_ARGS crt_file=data_files/server6.crt key_file=data_files/server6.key"
|
2014-02-27 14:38:29 +01:00
|
|
|
O_CLIENT_ARGS="$O_CLIENT_ARGS -cert data_files/server6.crt -key data_files/server6.key"
|
2014-03-13 16:21:59 +01:00
|
|
|
G_CLIENT_ARGS="$G_CLIENT_ARGS --x509certfile data_files/server6.crt --x509keyfile data_files/server6.key"
|
2014-02-27 14:38:29 +01:00
|
|
|
else
|
2016-09-04 23:31:09 +02:00
|
|
|
M_CLIENT_ARGS="$M_CLIENT_ARGS crt_file=none key_file=none"
|
2014-02-27 14:38:29 +01:00
|
|
|
fi
|
2014-02-19 13:35:52 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
"RSA")
|
2020-08-21 12:24:32 +02:00
|
|
|
M_SERVER_ARGS="$M_SERVER_ARGS crt_file=data_files/server2-sha256.crt key_file=data_files/server2.key"
|
|
|
|
O_SERVER_ARGS="$O_SERVER_ARGS -cert data_files/server2-sha256.crt -key data_files/server2.key"
|
|
|
|
G_SERVER_ARGS="$G_SERVER_ARGS --x509certfile data_files/server2-sha256.crt --x509keyfile data_files/server2.key"
|
2014-02-28 12:42:57 +01:00
|
|
|
|
2014-02-27 14:38:29 +01:00
|
|
|
if [ "X$VERIFY" = "XYES" ]; then
|
2020-08-21 12:24:32 +02:00
|
|
|
M_CLIENT_ARGS="$M_CLIENT_ARGS crt_file=data_files/cert_sha256.crt key_file=data_files/server1.key"
|
|
|
|
O_CLIENT_ARGS="$O_CLIENT_ARGS -cert data_files/cert_sha256.crt -key data_files/server1.key"
|
|
|
|
G_CLIENT_ARGS="$G_CLIENT_ARGS --x509certfile data_files/cert_sha256.crt --x509keyfile data_files/server1.key"
|
2014-02-27 14:38:29 +01:00
|
|
|
else
|
2016-09-04 23:31:09 +02:00
|
|
|
M_CLIENT_ARGS="$M_CLIENT_ARGS crt_file=none key_file=none"
|
2014-02-27 14:38:29 +01:00
|
|
|
fi
|
2014-02-19 13:35:52 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
"PSK")
|
2014-02-28 12:42:57 +01:00
|
|
|
# give RSA-PSK-capable server a RSA cert
|
2014-02-27 14:38:29 +01:00
|
|
|
# (should be a separate type, but harder to close with openssl)
|
2020-08-21 12:24:32 +02:00
|
|
|
M_SERVER_ARGS="$M_SERVER_ARGS psk=6162636465666768696a6b6c6d6e6f70 ca_file=none crt_file=data_files/server2-sha256.crt key_file=data_files/server2.key"
|
2014-02-27 14:38:29 +01:00
|
|
|
O_SERVER_ARGS="$O_SERVER_ARGS -psk 6162636465666768696a6b6c6d6e6f70 -nocert"
|
2020-08-21 12:24:32 +02:00
|
|
|
G_SERVER_ARGS="$G_SERVER_ARGS --x509certfile data_files/server2-sha256.crt --x509keyfile data_files/server2.key --pskpasswd data_files/passwd.psk"
|
2014-02-28 12:42:57 +01:00
|
|
|
|
2016-09-04 23:31:09 +02:00
|
|
|
M_CLIENT_ARGS="$M_CLIENT_ARGS psk=6162636465666768696a6b6c6d6e6f70 crt_file=none key_file=none"
|
2014-02-19 14:24:24 +01:00
|
|
|
O_CLIENT_ARGS="$O_CLIENT_ARGS -psk 6162636465666768696a6b6c6d6e6f70"
|
2014-03-13 16:21:59 +01:00
|
|
|
G_CLIENT_ARGS="$G_CLIENT_ARGS --pskusername Client_identity --pskkey=6162636465666768696a6b6c6d6e6f70"
|
2014-02-19 13:35:52 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2016-09-04 23:31:09 +02:00
|
|
|
# is_mbedtls <cmd_line>
|
|
|
|
is_mbedtls() {
|
2023-01-26 21:34:01 +01:00
|
|
|
case $1 in
|
|
|
|
*ssl_client2*) true;;
|
|
|
|
*ssl_server2*) true;;
|
|
|
|
*) false;;
|
|
|
|
esac
|
2014-02-27 15:37:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# has_mem_err <log_file_name>
|
|
|
|
has_mem_err() {
|
|
|
|
if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
|
|
|
|
grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
|
|
|
|
then
|
|
|
|
return 1 # false: does not have errors
|
|
|
|
else
|
|
|
|
return 0 # true: has errors
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-12-14 19:02:00 +01:00
|
|
|
# Wait for process $2 to be listening on port $1
|
|
|
|
if type lsof >/dev/null 2>/dev/null; then
|
|
|
|
wait_server_start() {
|
|
|
|
START_TIME=$(date +%s)
|
|
|
|
if is_dtls "$MODE"; then
|
|
|
|
proto=UDP
|
|
|
|
else
|
|
|
|
proto=TCP
|
|
|
|
fi
|
|
|
|
while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
|
|
|
|
if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
|
|
|
|
echo "SERVERSTART TIMEOUT"
|
|
|
|
echo "SERVERSTART TIMEOUT" >> $SRV_OUT
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
# Linux and *BSD support decimal arguments to sleep. On other
|
|
|
|
# OSes this may be a tight loop.
|
|
|
|
sleep 0.1 2>/dev/null || true
|
|
|
|
done
|
|
|
|
}
|
|
|
|
else
|
2018-01-08 12:38:15 +01:00
|
|
|
echo "Warning: lsof not available, wait_server_start = sleep"
|
2017-12-14 19:02:00 +01:00
|
|
|
wait_server_start() {
|
2018-01-22 10:22:09 +01:00
|
|
|
sleep 2
|
2017-12-14 19:02:00 +01:00
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2014-02-19 14:45:00 +01:00
|
|
|
# start_server <name>
|
|
|
|
# also saves name and command
|
|
|
|
start_server() {
|
|
|
|
case $1 in
|
|
|
|
[Oo]pen*)
|
Use OPENSSL everywhere, not OPENSSL_CMD
These variables were both uses to select the default version of OpenSSL
to use for tests:
- when running compat.sh or ssl-opt.sh directly, OPENSSL_CMD was used;
- when running all.sh, OPENSSL was used.
This caused surprising situations if you had one but not the other set
in your environment. For example I used to have OPENSSL_CMD set but not
OPENSSL, so ssl-opt.sh was failing in some all.sh components but passing
when I ran it manually in the same configuration and build, a rather
unpleasant experience.
The natural name would be OPENSSL, and that's what set in the Docker
images used by the CI. However back in the 1.3.x days, that name was
already used in library/Makefile, so it was preferable to pick a
different one, hence OPENSSL_CMD. However the build system has not been
using this name since at least Mbed TLS 2.0.0, so it's now free for use
again (as demonstrated by the fact that it's been set in the CI without
causing any trouble).
So, unify things and use OPENSSL everywhere. Just leave an error message
for the benefit of developers which might have OPENSSL_CMD, not OPENSSL,
set in their environment from the old days.
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-12-19 11:42:12 +01:00
|
|
|
SERVER_CMD="$OPENSSL s_server $O_SERVER_ARGS"
|
2014-02-19 14:45:00 +01:00
|
|
|
;;
|
2014-02-28 12:42:57 +01:00
|
|
|
[Gg]nu*)
|
2014-03-13 18:47:44 +01:00
|
|
|
SERVER_CMD="$GNUTLS_SERV $G_SERVER_ARGS --priority $G_SERVER_PRIO"
|
2014-02-28 12:42:57 +01:00
|
|
|
;;
|
2015-01-22 18:05:05 +01:00
|
|
|
mbed*)
|
2016-09-04 23:31:09 +02:00
|
|
|
SERVER_CMD="$M_SRV $M_SERVER_ARGS"
|
2014-02-27 15:37:24 +01:00
|
|
|
if [ "$MEMCHECK" -gt 0 ]; then
|
|
|
|
SERVER_CMD="valgrind --leak-check=full $SERVER_CMD"
|
|
|
|
fi
|
2014-02-19 14:45:00 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "error: invalid server name: $1" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
SERVER_NAME=$1
|
|
|
|
|
|
|
|
log "$SERVER_CMD"
|
2014-05-28 23:06:50 +02:00
|
|
|
echo "$SERVER_CMD" > $SRV_OUT
|
2014-07-11 17:01:06 +02:00
|
|
|
# for servers without -www or equivalent
|
2015-02-09 14:05:54 +01:00
|
|
|
while :; do echo bla; sleep 1; done | $SERVER_CMD >> $SRV_OUT 2>&1 &
|
2023-01-13 04:42:11 +01:00
|
|
|
SRV_PID=$!
|
2014-02-19 14:45:00 +01:00
|
|
|
|
2023-01-13 04:42:11 +01:00
|
|
|
wait_server_start "$PORT" "$SRV_PID"
|
2014-02-19 14:45:00 +01:00
|
|
|
}
|
|
|
|
|
2014-08-31 10:37:14 +02:00
|
|
|
# terminate the running server
|
2014-02-19 15:29:38 +01:00
|
|
|
stop_server() {
|
2023-01-13 04:42:11 +01:00
|
|
|
# For Ubuntu 22.04, `Terminated` message is outputed by wait command.
|
|
|
|
# To remove it from stdout, redirect stdout/stderr to SRV_OUT
|
|
|
|
kill $SRV_PID >/dev/null 2>&1
|
|
|
|
wait $SRV_PID >> $SRV_OUT 2>&1
|
2014-02-27 15:37:24 +01:00
|
|
|
|
|
|
|
if [ "$MEMCHECK" -gt 0 ]; then
|
2016-09-04 23:31:09 +02:00
|
|
|
if is_mbedtls "$SERVER_CMD" && has_mem_err $SRV_OUT; then
|
2014-02-27 15:37:24 +01:00
|
|
|
echo " ! Server had memory errors"
|
2014-08-31 10:22:11 +02:00
|
|
|
SRVMEM=$(( $SRVMEM + 1 ))
|
2014-02-27 15:37:24 +01:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2014-05-28 23:06:50 +02:00
|
|
|
rm -f $SRV_OUT
|
2014-02-19 15:29:38 +01:00
|
|
|
}
|
|
|
|
|
2014-02-25 16:21:22 +01:00
|
|
|
# kill the running server (used when killed by signal)
|
|
|
|
cleanup() {
|
2014-05-28 23:06:50 +02:00
|
|
|
rm -f $SRV_OUT $CLI_OUT
|
2023-01-13 04:42:11 +01:00
|
|
|
kill $SRV_PID >/dev/null 2>&1
|
2014-08-31 10:37:14 +02:00
|
|
|
kill $WATCHDOG_PID >/dev/null 2>&1
|
2014-02-25 16:21:22 +01:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2014-08-30 22:41:47 +02:00
|
|
|
# wait for client to terminate and set EXIT
|
|
|
|
# must be called right after starting the client
|
|
|
|
wait_client_done() {
|
|
|
|
CLI_PID=$!
|
|
|
|
|
|
|
|
( sleep "$DOG_DELAY"; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
|
|
|
|
WATCHDOG_PID=$!
|
|
|
|
|
2023-01-13 03:52:41 +01:00
|
|
|
# For Ubuntu 22.04, `Terminated` message is outputed by wait command.
|
|
|
|
# To remove it from stdout, redirect stdout/stderr to CLI_OUT
|
|
|
|
wait $CLI_PID >> $CLI_OUT 2>&1
|
2014-08-30 22:41:47 +02:00
|
|
|
EXIT=$?
|
|
|
|
|
2023-01-13 03:52:41 +01:00
|
|
|
kill $WATCHDOG_PID >/dev/null 2>&1
|
|
|
|
wait $WATCHDOG_PID >> $CLI_OUT 2>&1
|
2014-08-30 22:41:47 +02:00
|
|
|
|
|
|
|
echo "EXIT: $EXIT" >> $CLI_OUT
|
|
|
|
}
|
|
|
|
|
2023-02-20 07:58:03 +01:00
|
|
|
# record_outcome <outcome> [<failure-reason>]
|
|
|
|
record_outcome() {
|
|
|
|
echo "$1"
|
|
|
|
if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ]; then
|
|
|
|
# The test outcome file has the format (in single line):
|
|
|
|
# platform;configuration;
|
|
|
|
# test suite name;test case description;
|
|
|
|
# PASS/FAIL/SKIP;[failure cause]
|
|
|
|
printf '%s;%s;%s;%s;%s;%s\n' \
|
|
|
|
"$MBEDTLS_TEST_PLATFORM" "$MBEDTLS_TEST_CONFIGURATION" \
|
|
|
|
"compat" "$TITLE" \
|
|
|
|
"$1" "${2-}" \
|
|
|
|
>> "$MBEDTLS_TEST_OUTCOME_FILE"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-02-20 08:49:10 +01:00
|
|
|
# display additional information if test case fails
|
|
|
|
report_fail() {
|
2023-02-20 07:58:03 +01:00
|
|
|
FAIL_PROMPT="outputs saved to c-srv-${TESTS}.log, c-cli-${TESTS}.log"
|
|
|
|
record_outcome "FAIL" "$FAIL_PROMPT"
|
2023-02-20 08:49:10 +01:00
|
|
|
cp $SRV_OUT c-srv-${TESTS}.log
|
|
|
|
cp $CLI_OUT c-cli-${TESTS}.log
|
2023-02-20 07:58:03 +01:00
|
|
|
echo " ! $FAIL_PROMPT"
|
2023-02-20 08:49:10 +01:00
|
|
|
|
|
|
|
if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
|
|
|
|
echo " ! server output:"
|
|
|
|
cat c-srv-${TESTS}.log
|
|
|
|
echo " ! ==================================================="
|
|
|
|
echo " ! client output:"
|
|
|
|
cat c-cli-${TESTS}.log
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-01-26 21:16:34 +01:00
|
|
|
# run_client PROGRAM_NAME STANDARD_CIPHER_SUITE PROGRAM_CIPHER_SUITE
|
2014-02-19 15:23:21 +01:00
|
|
|
run_client() {
|
2014-02-27 11:12:30 +01:00
|
|
|
# announce what we're going to do
|
2014-08-31 10:22:11 +02:00
|
|
|
TESTS=$(( $TESTS + 1 ))
|
2023-01-26 21:34:01 +01:00
|
|
|
TITLE="${1%"${1#?}"}->${SERVER_NAME%"${SERVER_NAME#?}"}"
|
2014-08-31 10:22:11 +02:00
|
|
|
TITLE="$TITLE $MODE,$VERIF $2"
|
2023-02-01 04:09:37 +01:00
|
|
|
DOTS72="........................................................................"
|
|
|
|
printf "%s %.*s " "$TITLE" "$((71 - ${#TITLE}))" "$DOTS72"
|
2014-02-27 11:12:30 +01:00
|
|
|
|
2014-07-11 17:41:24 +02:00
|
|
|
# should we skip?
|
|
|
|
if [ "X$SKIP_NEXT" = "XYES" ]; then
|
|
|
|
SKIP_NEXT="NO"
|
2023-02-20 07:58:03 +01:00
|
|
|
record_outcome "SKIP"
|
2014-07-11 17:41:24 +02:00
|
|
|
SKIPPED=$(( $SKIPPED + 1 ))
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2014-02-19 15:23:21 +01:00
|
|
|
# run the command and interpret result
|
|
|
|
case $1 in
|
|
|
|
[Oo]pen*)
|
2023-01-26 21:16:34 +01:00
|
|
|
CLIENT_CMD="$OPENSSL s_client $O_CLIENT_ARGS -cipher $3"
|
2014-02-19 15:23:21 +01:00
|
|
|
log "$CLIENT_CMD"
|
2014-05-28 23:06:50 +02:00
|
|
|
echo "$CLIENT_CMD" > $CLI_OUT
|
2015-08-04 17:15:13 +02:00
|
|
|
printf 'GET HTTP/1.0\r\n\r\n' | $CLIENT_CMD >> $CLI_OUT 2>&1 &
|
2014-08-30 22:41:47 +02:00
|
|
|
wait_client_done
|
2014-02-19 15:23:21 +01:00
|
|
|
|
2014-08-31 10:22:11 +02:00
|
|
|
if [ $EXIT -eq 0 ]; then
|
2014-02-19 15:23:21 +01:00
|
|
|
RESULT=0
|
|
|
|
else
|
2023-02-23 08:24:47 +01:00
|
|
|
# If it is NULL cipher ...
|
2014-05-28 23:06:50 +02:00
|
|
|
if grep 'Cipher is (NONE)' $CLI_OUT >/dev/null; then
|
2014-02-19 15:23:21 +01:00
|
|
|
RESULT=1
|
|
|
|
else
|
|
|
|
RESULT=2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
2014-03-13 16:21:59 +01:00
|
|
|
[Gg]nu*)
|
2014-07-10 20:12:56 +02:00
|
|
|
# need to force IPv4 with UDP, but keep localhost for auth
|
|
|
|
if is_dtls "$MODE"; then
|
|
|
|
G_HOST="127.0.0.1"
|
|
|
|
else
|
|
|
|
G_HOST="localhost"
|
|
|
|
fi
|
2023-01-26 21:16:34 +01:00
|
|
|
CLIENT_CMD="$GNUTLS_CLI $G_CLIENT_ARGS --priority $G_PRIO_MODE:$3 $G_HOST"
|
2014-03-13 16:21:59 +01:00
|
|
|
log "$CLIENT_CMD"
|
2014-05-28 23:06:50 +02:00
|
|
|
echo "$CLIENT_CMD" > $CLI_OUT
|
2015-08-04 17:15:13 +02:00
|
|
|
printf 'GET HTTP/1.0\r\n\r\n' | $CLIENT_CMD >> $CLI_OUT 2>&1 &
|
2014-08-30 22:41:47 +02:00
|
|
|
wait_client_done
|
2014-03-13 16:21:59 +01:00
|
|
|
|
2014-08-31 10:22:11 +02:00
|
|
|
if [ $EXIT -eq 0 ]; then
|
2014-03-13 16:21:59 +01:00
|
|
|
RESULT=0
|
|
|
|
else
|
2014-03-13 17:45:35 +01:00
|
|
|
RESULT=2
|
|
|
|
# interpret early failure, with a handshake_failure alert
|
|
|
|
# before the server hello, as "no ciphersuite in common"
|
2014-05-28 23:06:50 +02:00
|
|
|
if grep -F 'Received alert [40]: Handshake failed' $CLI_OUT; then
|
|
|
|
if grep -i 'SERVER HELLO .* was received' $CLI_OUT; then :
|
2014-03-13 17:45:35 +01:00
|
|
|
else
|
|
|
|
RESULT=1
|
|
|
|
fi
|
|
|
|
fi >/dev/null
|
2014-03-13 16:21:59 +01:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
2015-01-22 18:05:05 +01:00
|
|
|
mbed*)
|
2023-01-26 21:16:34 +01:00
|
|
|
CLIENT_CMD="$M_CLI $M_CLIENT_ARGS force_ciphersuite=$3"
|
2014-02-27 15:37:24 +01:00
|
|
|
if [ "$MEMCHECK" -gt 0 ]; then
|
|
|
|
CLIENT_CMD="valgrind --leak-check=full $CLIENT_CMD"
|
|
|
|
fi
|
2014-02-19 15:23:21 +01:00
|
|
|
log "$CLIENT_CMD"
|
2014-05-28 23:06:50 +02:00
|
|
|
echo "$CLIENT_CMD" > $CLI_OUT
|
2014-08-30 22:41:47 +02:00
|
|
|
$CLIENT_CMD >> $CLI_OUT 2>&1 &
|
|
|
|
wait_client_done
|
2014-02-19 15:23:21 +01:00
|
|
|
|
|
|
|
case $EXIT in
|
2016-09-04 23:31:09 +02:00
|
|
|
# Success
|
2014-02-19 15:23:21 +01:00
|
|
|
"0") RESULT=0 ;;
|
2016-09-04 23:31:09 +02:00
|
|
|
|
|
|
|
# Ciphersuite not supported
|
2014-02-19 15:23:21 +01:00
|
|
|
"2") RESULT=1 ;;
|
2016-09-04 23:31:09 +02:00
|
|
|
|
|
|
|
# Error
|
2014-02-19 15:23:21 +01:00
|
|
|
*) RESULT=2 ;;
|
|
|
|
esac
|
2014-02-27 15:37:24 +01:00
|
|
|
|
|
|
|
if [ "$MEMCHECK" -gt 0 ]; then
|
2016-09-04 23:31:09 +02:00
|
|
|
if is_mbedtls "$CLIENT_CMD" && has_mem_err $CLI_OUT; then
|
2014-02-27 15:37:24 +01:00
|
|
|
RESULT=2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2014-02-19 15:23:21 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "error: invalid client name: $1" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2014-05-28 23:06:50 +02:00
|
|
|
echo "EXIT: $EXIT" >> $CLI_OUT
|
2014-03-25 14:16:44 +01:00
|
|
|
|
2014-02-19 15:23:21 +01:00
|
|
|
# report and count result
|
|
|
|
case $RESULT in
|
|
|
|
"0")
|
2023-02-20 07:58:03 +01:00
|
|
|
record_outcome "PASS"
|
2014-02-19 15:23:21 +01:00
|
|
|
;;
|
|
|
|
"1")
|
2023-02-20 07:58:03 +01:00
|
|
|
record_outcome "SKIP"
|
2014-08-31 10:22:11 +02:00
|
|
|
SKIPPED=$(( $SKIPPED + 1 ))
|
2014-02-19 15:23:21 +01:00
|
|
|
;;
|
|
|
|
"2")
|
2023-02-20 08:49:10 +01:00
|
|
|
report_fail
|
2014-08-31 10:22:11 +02:00
|
|
|
FAILED=$(( $FAILED + 1 ))
|
2014-02-19 15:23:21 +01:00
|
|
|
;;
|
|
|
|
esac
|
2014-02-27 11:12:30 +01:00
|
|
|
|
2014-05-28 23:06:50 +02:00
|
|
|
rm -f $CLI_OUT
|
2014-02-19 15:23:21 +01:00
|
|
|
}
|
|
|
|
|
2014-02-26 18:21:02 +01:00
|
|
|
#
|
|
|
|
# MAIN
|
|
|
|
#
|
|
|
|
|
2014-03-14 18:13:53 +01:00
|
|
|
get_options "$@"
|
|
|
|
|
2023-02-20 07:58:03 +01:00
|
|
|
# Make the outcome file path relative to the original directory, not
|
|
|
|
# to .../tests
|
|
|
|
case "$MBEDTLS_TEST_OUTCOME_FILE" in
|
|
|
|
[!/]*)
|
|
|
|
MBEDTLS_TEST_OUTCOME_FILE="$ORIGINAL_PWD/$MBEDTLS_TEST_OUTCOME_FILE"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2014-02-27 12:25:54 +01:00
|
|
|
# sanity checks, avoid an avalanche of errors
|
2016-09-04 23:31:09 +02:00
|
|
|
if [ ! -x "$M_SRV" ]; then
|
|
|
|
echo "Command '$M_SRV' is not an executable file" >&2
|
2014-02-27 12:25:54 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2016-09-04 23:31:09 +02:00
|
|
|
if [ ! -x "$M_CLI" ]; then
|
|
|
|
echo "Command '$M_CLI' is not an executable file" >&2
|
2014-02-27 12:25:54 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2014-03-14 18:13:53 +01:00
|
|
|
|
|
|
|
if echo "$PEERS" | grep -i openssl > /dev/null; then
|
Use OPENSSL everywhere, not OPENSSL_CMD
These variables were both uses to select the default version of OpenSSL
to use for tests:
- when running compat.sh or ssl-opt.sh directly, OPENSSL_CMD was used;
- when running all.sh, OPENSSL was used.
This caused surprising situations if you had one but not the other set
in your environment. For example I used to have OPENSSL_CMD set but not
OPENSSL, so ssl-opt.sh was failing in some all.sh components but passing
when I ran it manually in the same configuration and build, a rather
unpleasant experience.
The natural name would be OPENSSL, and that's what set in the Docker
images used by the CI. However back in the 1.3.x days, that name was
already used in library/Makefile, so it was preferable to pick a
different one, hence OPENSSL_CMD. However the build system has not been
using this name since at least Mbed TLS 2.0.0, so it's now free for use
again (as demonstrated by the fact that it's been set in the CI without
causing any trouble).
So, unify things and use OPENSSL everywhere. Just leave an error message
for the benefit of developers which might have OPENSSL_CMD, not OPENSSL,
set in their environment from the old days.
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-12-19 11:42:12 +01:00
|
|
|
if which "$OPENSSL" >/dev/null 2>&1; then :; else
|
|
|
|
echo "Command '$OPENSSL' not found" >&2
|
2014-03-13 18:47:44 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2014-03-14 18:13:53 +01:00
|
|
|
fi
|
2014-02-27 12:25:54 +01:00
|
|
|
|
2014-03-14 18:13:53 +01:00
|
|
|
if echo "$PEERS" | grep -i gnutls > /dev/null; then
|
|
|
|
for CMD in "$GNUTLS_CLI" "$GNUTLS_SERV"; do
|
|
|
|
if which "$CMD" >/dev/null 2>&1; then :; else
|
|
|
|
echo "Command '$CMD' not found" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
for PEER in $PEERS; do
|
|
|
|
case "$PEER" in
|
2015-01-22 18:05:05 +01:00
|
|
|
mbed*|[Oo]pen*|[Gg]nu*)
|
2014-03-14 18:13:53 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown peers: $PEER" >&2
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
done
|
2014-02-26 18:21:02 +01:00
|
|
|
|
2014-05-28 22:59:30 +02:00
|
|
|
# Pick a "unique" port in the range 10000-19999.
|
|
|
|
PORT="0000$$"
|
2014-06-16 16:54:36 +02:00
|
|
|
PORT="1$(echo $PORT | tail -c 5)"
|
2014-05-28 22:59:30 +02:00
|
|
|
|
2014-05-28 23:06:50 +02:00
|
|
|
# Also pick a unique name for intermediate files
|
|
|
|
SRV_OUT="srv_out.$$"
|
|
|
|
CLI_OUT="cli_out.$$"
|
|
|
|
|
2014-08-30 22:41:47 +02:00
|
|
|
# client timeout delay: be more patient with valgrind
|
|
|
|
if [ "$MEMCHECK" -gt 0 ]; then
|
|
|
|
DOG_DELAY=30
|
|
|
|
else
|
|
|
|
DOG_DELAY=10
|
|
|
|
fi
|
|
|
|
|
2014-07-11 17:41:24 +02:00
|
|
|
SKIP_NEXT="NO"
|
|
|
|
|
2014-02-25 16:21:22 +01:00
|
|
|
trap cleanup INT TERM HUP
|
|
|
|
|
2023-02-07 03:41:04 +01:00
|
|
|
for MODE in $MODES; do
|
2023-02-08 05:38:31 +01:00
|
|
|
for TYPE in $TYPES; do
|
|
|
|
|
|
|
|
# PSK cipher suites do not allow client certificate verification.
|
|
|
|
# This means PSK test cases with VERIFY=YES should be replaced by
|
|
|
|
# VERIFY=NO or be ignored. SUB_VERIFIES variable is used to constrain
|
|
|
|
# verification option for PSK test cases.
|
|
|
|
SUB_VERIFIES=$VERIFIES
|
|
|
|
if [ "$TYPE" = "PSK" ]; then
|
|
|
|
SUB_VERIFIES="NO"
|
|
|
|
fi
|
2023-02-07 03:41:04 +01:00
|
|
|
|
2023-02-08 05:38:31 +01:00
|
|
|
for VERIFY in $SUB_VERIFIES; do
|
|
|
|
VERIF=$(echo $VERIFY | tr '[:upper:]' '[:lower:]')
|
2014-03-13 17:45:35 +01:00
|
|
|
for PEER in $PEERS; do
|
2013-04-17 19:27:58 +02:00
|
|
|
|
2014-02-19 15:29:38 +01:00
|
|
|
setup_arguments
|
2014-02-28 12:42:57 +01:00
|
|
|
|
2014-03-13 17:45:35 +01:00
|
|
|
case "$PEER" in
|
|
|
|
|
|
|
|
[Oo]pen*)
|
|
|
|
|
2015-08-04 16:43:37 +02:00
|
|
|
if test "$OSSL_NO_DTLS" -gt 0 && is_dtls "$MODE"; then
|
|
|
|
continue;
|
|
|
|
fi
|
|
|
|
|
2022-03-23 14:14:19 +01:00
|
|
|
# OpenSSL <1.0.2 doesn't support DTLS 1.2. Check if OpenSSL
|
|
|
|
# supports $O_MODE from the s_server help. (The s_client
|
|
|
|
# help isn't accurate as of 1.0.2g: it supports DTLS 1.2
|
|
|
|
# but doesn't list it. But the s_server help seems to be
|
|
|
|
# accurate.)
|
Use OPENSSL everywhere, not OPENSSL_CMD
These variables were both uses to select the default version of OpenSSL
to use for tests:
- when running compat.sh or ssl-opt.sh directly, OPENSSL_CMD was used;
- when running all.sh, OPENSSL was used.
This caused surprising situations if you had one but not the other set
in your environment. For example I used to have OPENSSL_CMD set but not
OPENSSL, so ssl-opt.sh was failing in some all.sh components but passing
when I ran it manually in the same configuration and build, a rather
unpleasant experience.
The natural name would be OPENSSL, and that's what set in the Docker
images used by the CI. However back in the 1.3.x days, that name was
already used in library/Makefile, so it was preferable to pick a
different one, hence OPENSSL_CMD. However the build system has not been
using this name since at least Mbed TLS 2.0.0, so it's now free for use
again (as demonstrated by the fact that it's been set in the CI without
causing any trouble).
So, unify things and use OPENSSL everywhere. Just leave an error message
for the benefit of developers which might have OPENSSL_CMD, not OPENSSL,
set in their environment from the old days.
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-12-19 11:42:12 +01:00
|
|
|
if ! $OPENSSL s_server -help 2>&1 | grep -q "^ *-$O_MODE "; then
|
2022-03-23 14:14:19 +01:00
|
|
|
continue;
|
|
|
|
fi
|
|
|
|
|
2014-03-13 17:45:35 +01:00
|
|
|
reset_ciphersuites
|
2014-03-25 19:07:28 +01:00
|
|
|
add_common_ciphersuites
|
2014-03-13 17:45:35 +01:00
|
|
|
add_openssl_ciphersuites
|
|
|
|
filter_ciphersuites
|
|
|
|
|
2016-09-04 23:31:09 +02:00
|
|
|
if [ "X" != "X$M_CIPHERS" ]; then
|
2014-03-13 17:45:35 +01:00
|
|
|
start_server "OpenSSL"
|
2023-01-26 21:16:34 +01:00
|
|
|
translate_ciphers m $M_CIPHERS
|
|
|
|
for i in $ciphers; do
|
2023-02-21 07:19:27 +01:00
|
|
|
o_check_ciphersuite "${i%%=*}"
|
2023-01-26 21:16:34 +01:00
|
|
|
run_client mbedTLS ${i%%=*} ${i#*=}
|
2014-03-13 17:45:35 +01:00
|
|
|
done
|
|
|
|
stop_server
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "X" != "X$O_CIPHERS" ]; then
|
2015-01-22 17:43:54 +01:00
|
|
|
start_server "mbedTLS"
|
2023-01-26 21:16:34 +01:00
|
|
|
translate_ciphers o $O_CIPHERS
|
|
|
|
for i in $ciphers; do
|
2023-02-22 05:17:26 +01:00
|
|
|
o_check_ciphersuite "${i%%=*}"
|
2023-01-26 21:16:34 +01:00
|
|
|
run_client OpenSSL ${i%%=*} ${i#*=}
|
2014-03-13 17:45:35 +01:00
|
|
|
done
|
|
|
|
stop_server
|
|
|
|
fi
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
[Gg]nu*)
|
|
|
|
|
|
|
|
reset_ciphersuites
|
2014-03-25 19:07:28 +01:00
|
|
|
add_common_ciphersuites
|
2014-03-13 17:45:35 +01:00
|
|
|
add_gnutls_ciphersuites
|
|
|
|
filter_ciphersuites
|
|
|
|
|
2016-09-04 23:31:09 +02:00
|
|
|
if [ "X" != "X$M_CIPHERS" ]; then
|
2014-03-13 17:45:35 +01:00
|
|
|
start_server "GnuTLS"
|
2023-01-26 21:16:34 +01:00
|
|
|
translate_ciphers m $M_CIPHERS
|
|
|
|
for i in $ciphers; do
|
|
|
|
run_client mbedTLS ${i%%=*} ${i#*=}
|
2014-03-13 17:45:35 +01:00
|
|
|
done
|
|
|
|
stop_server
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "X" != "X$G_CIPHERS" ]; then
|
2015-01-22 17:43:54 +01:00
|
|
|
start_server "mbedTLS"
|
2023-01-26 21:16:34 +01:00
|
|
|
translate_ciphers g $G_CIPHERS
|
|
|
|
for i in $ciphers; do
|
|
|
|
run_client GnuTLS ${i%%=*} ${i#*=}
|
2014-03-13 17:45:35 +01:00
|
|
|
done
|
|
|
|
stop_server
|
|
|
|
fi
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
2015-01-22 18:05:05 +01:00
|
|
|
mbed*)
|
2014-03-13 17:45:35 +01:00
|
|
|
|
|
|
|
reset_ciphersuites
|
2014-03-25 19:07:28 +01:00
|
|
|
add_common_ciphersuites
|
2014-03-13 17:45:35 +01:00
|
|
|
add_openssl_ciphersuites
|
|
|
|
add_gnutls_ciphersuites
|
2015-04-08 12:49:31 +02:00
|
|
|
add_mbedtls_ciphersuites
|
2014-03-13 17:45:35 +01:00
|
|
|
filter_ciphersuites
|
|
|
|
|
2016-09-04 23:31:09 +02:00
|
|
|
if [ "X" != "X$M_CIPHERS" ]; then
|
2015-01-22 17:43:54 +01:00
|
|
|
start_server "mbedTLS"
|
2023-01-26 21:16:34 +01:00
|
|
|
translate_ciphers m $M_CIPHERS
|
|
|
|
for i in $ciphers; do
|
|
|
|
run_client mbedTLS ${i%%=*} ${i#*=}
|
2014-03-13 17:45:35 +01:00
|
|
|
done
|
|
|
|
stop_server
|
|
|
|
fi
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
2014-03-25 18:04:59 +01:00
|
|
|
*)
|
2014-05-22 15:47:58 +02:00
|
|
|
echo "Unknown peer: $PEER" >&2
|
2014-03-25 18:04:59 +01:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
|
2014-03-13 17:45:35 +01:00
|
|
|
esac
|
|
|
|
|
|
|
|
done
|
2014-02-19 15:29:38 +01:00
|
|
|
done
|
|
|
|
done
|
2013-08-27 19:57:15 +02:00
|
|
|
done
|
2013-08-27 22:00:47 +02:00
|
|
|
|
2014-02-24 13:20:14 +01:00
|
|
|
echo "------------------------------------------------------------------------"
|
2013-08-27 22:00:47 +02:00
|
|
|
|
2023-01-13 13:13:41 +01:00
|
|
|
if [ $FAILED -ne 0 -o $SRVMEM -ne 0 ]; then
|
2014-12-11 11:51:28 +01:00
|
|
|
printf "FAILED"
|
2013-08-27 22:00:47 +02:00
|
|
|
else
|
2014-12-11 11:51:28 +01:00
|
|
|
printf "PASSED"
|
2013-08-27 22:00:47 +02:00
|
|
|
fi
|
|
|
|
|
2014-03-13 17:57:45 +01:00
|
|
|
if [ "$MEMCHECK" -gt 0 ]; then
|
2014-08-31 10:22:11 +02:00
|
|
|
MEMREPORT=", $SRVMEM server memory errors"
|
2014-03-13 17:57:45 +01:00
|
|
|
else
|
|
|
|
MEMREPORT=""
|
|
|
|
fi
|
|
|
|
|
2014-08-31 10:22:11 +02:00
|
|
|
PASSED=$(( $TESTS - $FAILED ))
|
|
|
|
echo " ($PASSED / $TESTS tests ($SKIPPED skipped$MEMREPORT))"
|
2013-08-27 22:00:47 +02:00
|
|
|
|
2014-08-31 10:22:11 +02:00
|
|
|
FAILED=$(( $FAILED + $SRVMEM ))
|
2023-01-13 13:13:41 +01:00
|
|
|
if [ $FAILED -gt 255 ]; then
|
|
|
|
# Clamp at 255 as caller gets exit code & 0xFF
|
|
|
|
# (so 256 would be 0, or success, etc)
|
|
|
|
FAILED=255
|
|
|
|
fi
|
2014-08-31 10:22:11 +02:00
|
|
|
exit $FAILED
|