mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
Resolved merge conflicts caused by file moved in #8226
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
This commit is contained in:
5058
tests/scripts/all.sh
5058
tests/scripts/all.sh
File diff suppressed because it is too large
Load Diff
@ -357,6 +357,12 @@ KNOWN_TASKS = {
|
||||
'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
|
||||
re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
|
||||
],
|
||||
# Encrypted keys are not supported so far.
|
||||
'ssl-opt': [
|
||||
'TLS: password protected server key',
|
||||
'TLS: password protected client key',
|
||||
'TLS: password protected server key, two certificates',
|
||||
],
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -636,8 +642,9 @@ KNOWN_TASKS = {
|
||||
re.compile(r'mbedtls_ct_memmove_left .*')
|
||||
],
|
||||
'test_suite_psa_crypto': [
|
||||
# We don't support generate_key_ext entry points
|
||||
# We don't support generate_key_custom entry points
|
||||
# in drivers yet.
|
||||
re.compile(r'PSA generate key custom: RSA, e=.*'),
|
||||
re.compile(r'PSA generate key ext: RSA, e=.*'),
|
||||
],
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
This script is used to audit the validity date of crt/crl/csr used for testing.
|
||||
It prints the information about X.509 objects excluding the objects that
|
||||
are valid throughout the desired validity period. The data are collected
|
||||
from tests/data_files/ and tests/suites/*.data files by default.
|
||||
from framework/data_files/ and tests/suites/*.data files by default.
|
||||
"""
|
||||
|
||||
import os
|
||||
@ -269,12 +269,12 @@ class Auditor:
|
||||
|
||||
|
||||
class TestDataAuditor(Auditor):
|
||||
"""Class for auditing files in `tests/data_files/`"""
|
||||
"""Class for auditing files in `framework/data_files/`"""
|
||||
|
||||
def collect_default_files(self):
|
||||
"""Collect all files in `tests/data_files/`"""
|
||||
test_dir = self.find_test_dir()
|
||||
test_data_glob = os.path.join(test_dir, 'data_files/**')
|
||||
"""Collect all files in `framework/data_files/`"""
|
||||
test_data_glob = os.path.join(build_tree.guess_mbedtls_root(),
|
||||
'framework', 'data_files/**')
|
||||
data_files = [f for f in glob.glob(test_data_glob, recursive=True)
|
||||
if os.path.isfile(f)]
|
||||
return data_files
|
||||
|
@ -35,6 +35,8 @@ if [ -d library -a -d include -a -d tests ]; then :; else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MBEDTLS_ROOT_DIR="$PWD"
|
||||
|
||||
: ${OPENSSL:="openssl"}
|
||||
: ${GNUTLS_CLI:="gnutls-cli"}
|
||||
: ${GNUTLS_SERV:="gnutls-serv"}
|
||||
@ -79,7 +81,11 @@ make
|
||||
|
||||
# Step 2 - Execute the tests
|
||||
TEST_OUTPUT=out_${PPID}
|
||||
cd tests
|
||||
cd $MBEDTLS_ROOT_DIR/tests
|
||||
if [ ! -f "seedfile" ]; then
|
||||
dd if=/dev/urandom of="seedfile" bs=64 count=1
|
||||
fi
|
||||
cd $MBEDTLS_ROOT_DIR/tf-psa-crypto/tests
|
||||
if [ ! -f "seedfile" ]; then
|
||||
dd if=/dev/urandom of="seedfile" bs=64 count=1
|
||||
fi
|
||||
@ -87,10 +93,14 @@ echo
|
||||
|
||||
# Step 2a - Unit Tests (keep going even if some tests fail)
|
||||
echo '################ Unit tests ################'
|
||||
perl scripts/run-test-suites.pl -v 2 |tee unit-test-$TEST_OUTPUT
|
||||
cd $MBEDTLS_ROOT_DIR/tests
|
||||
perl scripts/run-test-suites.pl -v 2 |tee tls-x509-unit-test-$TEST_OUTPUT
|
||||
cd $MBEDTLS_ROOT_DIR/tf-psa-crypto/tests
|
||||
perl $MBEDTLS_ROOT_DIR/tests/scripts/run-test-suites.pl -v 2 |tee ../../tests/crypto-unit-test-$TEST_OUTPUT
|
||||
echo '^^^^^^^^^^^^^^^^ Unit tests ^^^^^^^^^^^^^^^^'
|
||||
echo
|
||||
|
||||
cd $MBEDTLS_ROOT_DIR/tests
|
||||
# Step 2b - System Tests (keep going even if some tests fail)
|
||||
echo
|
||||
echo '################ ssl-opt.sh ################'
|
||||
@ -141,13 +151,13 @@ rm -f "tests/basic-build-test-$$.ok"
|
||||
|
||||
cd tests
|
||||
|
||||
# Step 4a - Unit tests
|
||||
echo "Unit tests - tests/scripts/run-test-suites.pl"
|
||||
# Step 4a - TLS and x509 unit tests
|
||||
echo "TLS and x509 unit tests - tests/scripts/run-test-suites.pl"
|
||||
|
||||
PASSED_TESTS=$(tail -n6 unit-test-$TEST_OUTPUT|sed -n -e 's/test cases passed :[\t]*\([0-9]*\)/\1/p'| tr -d ' ')
|
||||
SKIPPED_TESTS=$(tail -n6 unit-test-$TEST_OUTPUT|sed -n -e 's/skipped :[ \t]*\([0-9]*\)/\1/p'| tr -d ' ')
|
||||
TOTAL_SUITES=$(tail -n6 unit-test-$TEST_OUTPUT|sed -n -e 's/.* (\([0-9]*\) .*, [0-9]* tests run)/\1/p'| tr -d ' ')
|
||||
FAILED_TESTS=$(tail -n6 unit-test-$TEST_OUTPUT|sed -n -e 's/failed :[\t]*\([0-9]*\)/\1/p' |tr -d ' ')
|
||||
PASSED_TESTS=$(tail -n6 tls-x509-unit-test-$TEST_OUTPUT|sed -n -e 's/test cases passed :[\t]*\([0-9]*\)/\1/p'| tr -d ' ')
|
||||
SKIPPED_TESTS=$(tail -n6 tls-x509-unit-test-$TEST_OUTPUT|sed -n -e 's/skipped :[ \t]*\([0-9]*\)/\1/p'| tr -d ' ')
|
||||
TOTAL_SUITES=$(tail -n6 tls-x509-unit-test-$TEST_OUTPUT|sed -n -e 's/.* (\([0-9]*\) .*, [0-9]* tests run)/\1/p'| tr -d ' ')
|
||||
FAILED_TESTS=$(tail -n6 tls-x509-unit-test-$TEST_OUTPUT|sed -n -e 's/failed :[\t]*\([0-9]*\)/\1/p' |tr -d ' ')
|
||||
|
||||
echo "No test suites : $TOTAL_SUITES"
|
||||
echo "Passed : $PASSED_TESTS"
|
||||
@ -163,7 +173,29 @@ rm -f "tests/basic-build-test-$$.ok"
|
||||
TOTAL_AVAIL=$(($PASSED_TESTS + $FAILED_TESTS + $SKIPPED_TESTS))
|
||||
TOTAL_EXED=$(($PASSED_TESTS + $FAILED_TESTS))
|
||||
|
||||
# Step 4b - TLS Options tests
|
||||
# Step 4b - Crypto unit tests
|
||||
echo "Crypto unit tests - tests/scripts/run-test-suites.pl"
|
||||
|
||||
PASSED_TESTS=$(tail -n6 crypto-unit-test-$TEST_OUTPUT|sed -n -e 's/test cases passed :[\t]*\([0-9]*\)/\1/p'| tr -d ' ')
|
||||
SKIPPED_TESTS=$(tail -n6 crypto-unit-test-$TEST_OUTPUT|sed -n -e 's/skipped :[ \t]*\([0-9]*\)/\1/p'| tr -d ' ')
|
||||
TOTAL_SUITES=$(tail -n6 crypto-unit-test-$TEST_OUTPUT|sed -n -e 's/.* (\([0-9]*\) .*, [0-9]* tests run)/\1/p'| tr -d ' ')
|
||||
FAILED_TESTS=$(tail -n6 crypto-unit-test-$TEST_OUTPUT|sed -n -e 's/failed :[\t]*\([0-9]*\)/\1/p' |tr -d ' ')
|
||||
|
||||
echo "No test suites : $TOTAL_SUITES"
|
||||
echo "Passed : $PASSED_TESTS"
|
||||
echo "Failed : $FAILED_TESTS"
|
||||
echo "Skipped : $SKIPPED_TESTS"
|
||||
echo "Total exec'd tests : $(($PASSED_TESTS + $FAILED_TESTS))"
|
||||
echo "Total avail tests : $(($PASSED_TESTS + $FAILED_TESTS + $SKIPPED_TESTS))"
|
||||
echo
|
||||
|
||||
TOTAL_PASS=$(($TOTAL_PASS+$PASSED_TESTS))
|
||||
TOTAL_FAIL=$(($TOTAL_FAIL+$FAILED_TESTS))
|
||||
TOTAL_SKIP=$(($TOTAL_SKIP+$SKIPPED_TESTS))
|
||||
TOTAL_AVAIL=$(($TOTAL_AVAIL + $PASSED_TESTS + $FAILED_TESTS + $SKIPPED_TESTS))
|
||||
TOTAL_EXED=$(($TOTAL_EXED + $PASSED_TESTS + $FAILED_TESTS))
|
||||
|
||||
# Step 4c - TLS Options tests
|
||||
echo "TLS Options tests - tests/ssl-opt.sh"
|
||||
|
||||
PASSED_TESTS=$(tail -n5 sys-test-$TEST_OUTPUT|sed -n -e 's/.* (\([0-9]*\) \/ [0-9]* tests ([0-9]* skipped))$/\1/p')
|
||||
@ -185,7 +217,7 @@ rm -f "tests/basic-build-test-$$.ok"
|
||||
TOTAL_EXED=$(($TOTAL_EXED + $TOTAL_TESTS))
|
||||
|
||||
|
||||
# Step 4c - System Compatibility tests
|
||||
# Step 4d - System Compatibility tests
|
||||
echo "System/Compatibility tests - tests/compat.sh"
|
||||
|
||||
PASSED_TESTS=$(cat compat-test-$TEST_OUTPUT | sed -n -e 's/.* (\([0-9]*\) \/ [0-9]* tests ([0-9]* skipped))$/\1/p' | awk 'BEGIN{ s = 0 } { s += $1 } END{ print s }')
|
||||
@ -207,7 +239,7 @@ rm -f "tests/basic-build-test-$$.ok"
|
||||
TOTAL_EXED=$(($TOTAL_EXED + $EXED_TESTS))
|
||||
|
||||
|
||||
# Step 4d - Grand totals
|
||||
# Step 4e - Grand totals
|
||||
echo "-------------------------------------------------------------------------"
|
||||
echo "Total tests"
|
||||
|
||||
@ -219,12 +251,13 @@ rm -f "tests/basic-build-test-$$.ok"
|
||||
echo
|
||||
|
||||
|
||||
# Step 4e - Coverage report
|
||||
# Step 4f - Coverage report
|
||||
echo "Coverage statistics:"
|
||||
sed -n '1,/^Overall coverage/d; /%/p' cov-$TEST_OUTPUT
|
||||
echo
|
||||
|
||||
rm unit-test-$TEST_OUTPUT
|
||||
rm tls-x509-unit-test-$TEST_OUTPUT
|
||||
rm crypto-unit-test-$TEST_OUTPUT
|
||||
rm sys-test-$TEST_OUTPUT
|
||||
rm compat-test-$TEST_OUTPUT
|
||||
rm cov-$TEST_OUTPUT
|
||||
|
@ -31,9 +31,16 @@ in_tf_psa_crypto_repo () {
|
||||
}
|
||||
|
||||
if in_mbedtls_repo; then
|
||||
library_dir='library'
|
||||
if [ -d tf-psa-crypto ]; then
|
||||
crypto_core_dir='tf-psa-crypto/core'
|
||||
builtin_drivers_dir='tf-psa-crypto/drivers/builtin/src'
|
||||
else
|
||||
crypto_core_dir='library'
|
||||
builtin_drivers_dir='library'
|
||||
fi
|
||||
elif in_tf_psa_crypto_repo; then
|
||||
library_dir='core'
|
||||
crypto_core_dir='core'
|
||||
builtin_drivers_dir='drivers/builtin/src/'
|
||||
else
|
||||
echo "Must be run from Mbed TLS root or TF-PSA-Crypto root" >&2
|
||||
exit 1
|
||||
@ -82,7 +89,14 @@ check()
|
||||
fi
|
||||
done
|
||||
|
||||
"$SCRIPT"
|
||||
# In the case of the config tests, generate only the files to be checked
|
||||
# by the caller as they are divided into Mbed TLS and TF-PSA-Crypto
|
||||
# specific ones.
|
||||
if [ "${SCRIPT##*/}" = "generate_config_tests.py" ]; then
|
||||
"$SCRIPT" "$@"
|
||||
else
|
||||
"$SCRIPT"
|
||||
fi
|
||||
|
||||
# Compare the script output to the old files and remove backups
|
||||
for FILE in "$@"; do
|
||||
@ -127,19 +141,38 @@ check()
|
||||
# - scripts/make_generated_files.bat (to generate them under Windows)
|
||||
|
||||
# These checks are common to Mbed TLS and TF-PSA-Crypto
|
||||
|
||||
# The first case is temporary for the hybrid situation with a tf-psa-crypto
|
||||
# directory in Mbed TLS that is not just a TF-PSA-Crypto submodule.
|
||||
if [ -d tf-psa-crypto ]; then
|
||||
cd tf-psa-crypto
|
||||
check ../framework/scripts/generate_bignum_tests.py $(../framework/scripts/generate_bignum_tests.py --list)
|
||||
check ../framework/scripts/generate_config_tests.py tests/suites/test_suite_config.psa_boolean.data
|
||||
check ../framework/scripts/generate_ecp_tests.py $(../framework/scripts/generate_ecp_tests.py --list)
|
||||
check ../framework/scripts/generate_psa_tests.py $(../framework/scripts/generate_psa_tests.py --list)
|
||||
cd ..
|
||||
check framework/scripts/generate_config_tests.py tests/suites/test_suite_config.mbedtls_boolean.data
|
||||
else
|
||||
check framework/scripts/generate_bignum_tests.py $(framework/scripts/generate_bignum_tests.py --list)
|
||||
if in_tf_psa_crypto_repo; then
|
||||
check framework/scripts/generate_config_tests.py tests/suites/test_suite_config.psa_boolean.data
|
||||
else
|
||||
check framework/scripts/generate_config_tests.py tests/suites/test_suite_config.mbedtls_boolean.data
|
||||
fi
|
||||
check framework/scripts/generate_ecp_tests.py $(framework/scripts/generate_ecp_tests.py --list)
|
||||
check framework/scripts/generate_psa_tests.py $(framework/scripts/generate_psa_tests.py --list)
|
||||
fi
|
||||
|
||||
check scripts/generate_psa_constants.py programs/psa/psa_constant_names_generated.c
|
||||
check framework/scripts/generate_bignum_tests.py $(framework/scripts/generate_bignum_tests.py --list)
|
||||
check framework/scripts/generate_config_tests.py $(framework/scripts/generate_config_tests.py --list)
|
||||
check framework/scripts/generate_ecp_tests.py $(framework/scripts/generate_ecp_tests.py --list)
|
||||
check framework/scripts/generate_psa_tests.py $(framework/scripts/generate_psa_tests.py --list)
|
||||
check framework/scripts/generate_test_keys.py tests/src/test_keys.h
|
||||
check scripts/generate_driver_wrappers.py $library_dir/psa_crypto_driver_wrappers.h $library_dir/psa_crypto_driver_wrappers_no_static.c
|
||||
check scripts/generate_driver_wrappers.py ${crypto_core_dir}/psa_crypto_driver_wrappers.h \
|
||||
${crypto_core_dir}/psa_crypto_driver_wrappers_no_static.c
|
||||
|
||||
# Additional checks for Mbed TLS only
|
||||
if in_mbedtls_repo; then
|
||||
check scripts/generate_errors.pl library/error.c
|
||||
check scripts/generate_errors.pl ${builtin_drivers_dir}/error.c
|
||||
check scripts/generate_query_config.pl programs/test/query_config.c
|
||||
check scripts/generate_features.pl library/version_features.c
|
||||
check scripts/generate_features.pl ${builtin_drivers_dir}/version_features.c
|
||||
check scripts/generate_ssl_debug_helpers.py library/ssl_debug_helpers_generated.c
|
||||
check framework/scripts/generate_test_cert_macros.py tests/src/test_certs.h
|
||||
# generate_visualc_files enumerates source files (library/*.c). It doesn't
|
||||
|
@ -107,12 +107,12 @@ BINARY_FILE_PATH_RE_LIST = [
|
||||
r'docs/.*\.pdf\Z',
|
||||
r'docs/.*\.png\Z',
|
||||
r'programs/fuzz/corpuses/[^.]+\Z',
|
||||
r'tests/data_files/[^.]+\Z',
|
||||
r'tests/data_files/.*\.(crt|csr|db|der|key|pubkey)\Z',
|
||||
r'tests/data_files/.*\.req\.[^/]+\Z',
|
||||
r'tests/data_files/.*malformed[^/]+\Z',
|
||||
r'tests/data_files/format_pkcs12\.fmt\Z',
|
||||
r'tests/data_files/.*\.bin\Z',
|
||||
r'framework/data_files/[^.]+\Z',
|
||||
r'framework/data_files/.*\.(crt|csr|db|der|key|pubkey)\Z',
|
||||
r'framework/data_files/.*\.req\.[^/]+\Z',
|
||||
r'framework/data_files/.*malformed[^/]+\Z',
|
||||
r'framework/data_files/format_pkcs12\.fmt\Z',
|
||||
r'framework/data_files/.*\.bin\Z',
|
||||
]
|
||||
BINARY_FILE_PATH_RE = re.compile('|'.join(BINARY_FILE_PATH_RE_LIST))
|
||||
|
||||
@ -368,9 +368,8 @@ class LicenseIssueTracker(LineIssueTracker):
|
||||
heading = "License issue:"
|
||||
|
||||
LICENSE_EXEMPTION_RE_LIST = [
|
||||
# Third-party code, other than whitelisted third-party modules,
|
||||
# may be under a different license.
|
||||
r'3rdparty/(?!(p256-m)/.*)',
|
||||
# Exempt third-party drivers which may be under a different license
|
||||
r'tf-psa-crypto/drivers/(?=(everest)/.*)',
|
||||
# Documentation explaining the license may have accidental
|
||||
# false positives.
|
||||
r'(ChangeLog|LICENSE|framework\/LICENSE|[-0-9A-Z_a-z]+\.md)\Z',
|
||||
|
@ -240,15 +240,19 @@ class CodeParser():
|
||||
"include/psa/*.h",
|
||||
"tf-psa-crypto/include/psa/*.h",
|
||||
"tf-psa-crypto/drivers/builtin/include/mbedtls/*.h",
|
||||
"3rdparty/everest/include/everest/everest.h",
|
||||
"3rdparty/everest/include/everest/x25519.h"
|
||||
"tf-psa-crypto/drivers/everest/include/everest/everest.h",
|
||||
"tf-psa-crypto/drivers/everest/include/everest/x25519.h"
|
||||
])
|
||||
all_macros["internal"] = self.parse_macros([
|
||||
"library/*.h",
|
||||
"tf-psa-crypto/core/*.h",
|
||||
"tf-psa-crypto/drivers/builtin/src/*.h",
|
||||
"tests/include/test/drivers/*.h",
|
||||
])
|
||||
all_macros["private"] = self.parse_macros([
|
||||
"library/*.c",
|
||||
"tf-psa-crypto/core/*.c",
|
||||
"tf-psa-crypto/drivers/builtin/src/*.c",
|
||||
])
|
||||
enum_consts = self.parse_enum_consts([
|
||||
"include/mbedtls/*.h",
|
||||
@ -256,9 +260,13 @@ class CodeParser():
|
||||
"tf-psa-crypto/include/psa/*.h",
|
||||
"tf-psa-crypto/drivers/builtin/include/mbedtls/*.h",
|
||||
"library/*.h",
|
||||
"tf-psa-crypto/core/*.h",
|
||||
"tf-psa-crypto/drivers/builtin/src/*.h",
|
||||
"library/*.c",
|
||||
"3rdparty/everest/include/everest/everest.h",
|
||||
"3rdparty/everest/include/everest/x25519.h"
|
||||
"tf-psa-crypto/core/*.c",
|
||||
"tf-psa-crypto/drivers/builtin/src/*.c",
|
||||
"tf-psa-crypto/drivers/everest/include/everest/everest.h",
|
||||
"tf-psa-crypto/drivers/everest/include/everest/x25519.h"
|
||||
])
|
||||
identifiers, excluded_identifiers = self.parse_identifiers([
|
||||
"include/mbedtls/*.h",
|
||||
@ -266,21 +274,27 @@ class CodeParser():
|
||||
"tf-psa-crypto/include/psa/*.h",
|
||||
"tf-psa-crypto/drivers/builtin/include/mbedtls/*.h",
|
||||
"library/*.h",
|
||||
"3rdparty/everest/include/everest/everest.h",
|
||||
"3rdparty/everest/include/everest/x25519.h"
|
||||
], ["3rdparty/p256-m/p256-m/p256-m.h"])
|
||||
"tf-psa-crypto/core/*.h",
|
||||
"tf-psa-crypto/drivers/builtin/src/*.h",
|
||||
"tf-psa-crypto/drivers/everest/include/everest/everest.h",
|
||||
"tf-psa-crypto/drivers/everest/include/everest/x25519.h"
|
||||
], ["tf-psa-crypto/drivers/p256-m/p256-m/p256-m.h"])
|
||||
mbed_psa_words = self.parse_mbed_psa_words([
|
||||
"include/mbedtls/*.h",
|
||||
"include/psa/*.h",
|
||||
"tf-psa-crypto/include/psa/*.h",
|
||||
"tf-psa-crypto/drivers/builtin/include/mbedtls/*.h",
|
||||
"library/*.h",
|
||||
"3rdparty/everest/include/everest/everest.h",
|
||||
"3rdparty/everest/include/everest/x25519.h",
|
||||
"tf-psa-crypto/core/*.h",
|
||||
"tf-psa-crypto/drivers/builtin/src/*.h",
|
||||
"tf-psa-crypto/drivers/everest/include/everest/everest.h",
|
||||
"tf-psa-crypto/drivers/everest/include/everest/x25519.h",
|
||||
"library/*.c",
|
||||
"3rdparty/everest/library/everest.c",
|
||||
"3rdparty/everest/library/x25519.c"
|
||||
], ["library/psa_crypto_driver_wrappers.h"])
|
||||
"tf-psa-crypto/core/*.c",
|
||||
"tf-psa-crypto/drivers/builtin/src/*.c",
|
||||
"tf-psa-crypto/drivers/everest/library/everest.c",
|
||||
"tf-psa-crypto/drivers/everest/library/x25519.c"
|
||||
], ["tf-psa-crypto/core/psa_crypto_driver_wrappers.h"])
|
||||
symbols = self.parse_symbols()
|
||||
|
||||
# Remove identifier macros like mbedtls_printf or mbedtls_calloc
|
||||
|
@ -16,6 +16,9 @@ import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import scripts_path # pylint: disable=unused-import
|
||||
from mbedtls_framework import build_tree
|
||||
|
||||
class ScriptOutputError(ValueError):
|
||||
"""A kind of ValueError that indicates we found
|
||||
the script doesn't list test cases in an expected
|
||||
@ -130,13 +133,10 @@ option"""
|
||||
@staticmethod
|
||||
def collect_test_directories():
|
||||
"""Get the relative path for the TLS and Crypto test directories."""
|
||||
if os.path.isdir('tests'):
|
||||
tests_dir = 'tests'
|
||||
elif os.path.isdir('suites'):
|
||||
tests_dir = '.'
|
||||
elif os.path.isdir('../suites'):
|
||||
tests_dir = '..'
|
||||
directories = [tests_dir]
|
||||
mbedtls_root = build_tree.guess_mbedtls_root()
|
||||
directories = [os.path.join(mbedtls_root, 'tests'),
|
||||
os.path.join(mbedtls_root, 'tf-psa-crypto', 'tests')]
|
||||
directories = [os.path.relpath(p) for p in directories]
|
||||
return directories
|
||||
|
||||
def walk_all(self):
|
||||
@ -149,7 +149,8 @@ option"""
|
||||
|
||||
for sh_file in ['ssl-opt.sh', 'compat.sh']:
|
||||
sh_file = os.path.join(directory, sh_file)
|
||||
self.collect_from_script(sh_file)
|
||||
if os.path.isfile(sh_file):
|
||||
self.collect_from_script(sh_file)
|
||||
|
||||
class TestDescriptions(TestDescriptionExplorer):
|
||||
"""Collect the available test cases."""
|
||||
|
165
tests/scripts/components-basic-checks.sh
Normal file
165
tests/scripts/components-basic-checks.sh
Normal file
@ -0,0 +1,165 @@
|
||||
# components-basic-checks.sh
|
||||
#
|
||||
# Copyright The Mbed TLS Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
|
||||
# This file contains test components that are executed by all.sh
|
||||
|
||||
################################################################
|
||||
#### Basic checks
|
||||
################################################################
|
||||
|
||||
component_check_recursion () {
|
||||
msg "Check: recursion.pl" # < 1s
|
||||
tests/scripts/recursion.pl library/*.c
|
||||
tests/scripts/recursion.pl ${PSA_CORE_PATH}/*.c
|
||||
tests/scripts/recursion.pl ${BUILTIN_SRC_PATH}/*.c
|
||||
}
|
||||
|
||||
component_check_generated_files () {
|
||||
msg "Check: check-generated-files, files generated with make" # 2s
|
||||
make generated_files
|
||||
tests/scripts/check-generated-files.sh
|
||||
|
||||
msg "Check: check-generated-files -u, files present" # 2s
|
||||
tests/scripts/check-generated-files.sh -u
|
||||
# Check that the generated files are considered up to date.
|
||||
tests/scripts/check-generated-files.sh
|
||||
|
||||
msg "Check: check-generated-files -u, files absent" # 2s
|
||||
command make neat
|
||||
tests/scripts/check-generated-files.sh -u
|
||||
# Check that the generated files are considered up to date.
|
||||
tests/scripts/check-generated-files.sh
|
||||
|
||||
# This component ends with the generated files present in the source tree.
|
||||
# This is necessary for subsequent components!
|
||||
}
|
||||
|
||||
component_check_doxy_blocks () {
|
||||
msg "Check: doxygen markup outside doxygen blocks" # < 1s
|
||||
tests/scripts/check-doxy-blocks.pl
|
||||
}
|
||||
|
||||
component_check_files () {
|
||||
msg "Check: file sanity checks (permissions, encodings)" # < 1s
|
||||
tests/scripts/check_files.py
|
||||
}
|
||||
|
||||
component_check_changelog () {
|
||||
msg "Check: changelog entries" # < 1s
|
||||
rm -f ChangeLog.new
|
||||
scripts/assemble_changelog.py -o ChangeLog.new
|
||||
if [ -e ChangeLog.new ]; then
|
||||
# Show the diff for information. It isn't an error if the diff is
|
||||
# non-empty.
|
||||
diff -u ChangeLog ChangeLog.new || true
|
||||
rm ChangeLog.new
|
||||
fi
|
||||
}
|
||||
|
||||
component_check_names () {
|
||||
msg "Check: declared and exported names (builds the library)" # < 3s
|
||||
tests/scripts/check_names.py -v
|
||||
}
|
||||
|
||||
component_check_test_cases () {
|
||||
msg "Check: test case descriptions" # < 1s
|
||||
if [ $QUIET -eq 1 ]; then
|
||||
opt='--quiet'
|
||||
else
|
||||
opt=''
|
||||
fi
|
||||
tests/scripts/check_test_cases.py -q $opt
|
||||
unset opt
|
||||
}
|
||||
|
||||
component_check_test_dependencies () {
|
||||
msg "Check: test case dependencies: legacy vs PSA" # < 1s
|
||||
# The purpose of this component is to catch unjustified dependencies on
|
||||
# legacy feature macros (MBEDTLS_xxx) in PSA tests. Generally speaking,
|
||||
# PSA test should use PSA feature macros (PSA_WANT_xxx, more rarely
|
||||
# MBEDTLS_PSA_xxx).
|
||||
#
|
||||
# Most of the time, use of legacy MBEDTLS_xxx macros are mistakes, which
|
||||
# this component is meant to catch. However a few of them are justified,
|
||||
# mostly by the absence of a PSA equivalent, so this component includes a
|
||||
# list of expected exceptions.
|
||||
|
||||
found="check-test-deps-found-$$"
|
||||
expected="check-test-deps-expected-$$"
|
||||
|
||||
# Find legacy dependencies in PSA tests
|
||||
grep 'depends_on' \
|
||||
tf-psa-crypto/tests/suites/test_suite_psa*.data \
|
||||
tf-psa-crypto/tests/suites/test_suite_psa*.function |
|
||||
grep -Eo '!?MBEDTLS_[^: ]*' |
|
||||
grep -v -e MBEDTLS_PSA_ -e MBEDTLS_TEST_ |
|
||||
sort -u > $found
|
||||
|
||||
# Expected ones with justification - keep in sorted order by ASCII table!
|
||||
rm -f $expected
|
||||
# No PSA equivalent - WANT_KEY_TYPE_AES means all sizes
|
||||
echo "!MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH" >> $expected
|
||||
# No PSA equivalent - used to skip decryption tests in PSA-ECB, CBC/XTS/NIST_KW/DES
|
||||
echo "!MBEDTLS_BLOCK_CIPHER_NO_DECRYPT" >> $expected
|
||||
# MBEDTLS_ASN1_WRITE_C is used by import_rsa_made_up() in test_suite_psa_crypto
|
||||
# in order to build a fake RSA key of the wanted size based on
|
||||
# PSA_VENDOR_RSA_MAX_KEY_BITS. The legacy module is only used by
|
||||
# the test code and that's probably the most convenient way of achieving
|
||||
# the test's goal.
|
||||
echo "MBEDTLS_ASN1_WRITE_C" >> $expected
|
||||
# No PSA equivalent - we should probably have one in the future.
|
||||
echo "MBEDTLS_ECP_RESTARTABLE" >> $expected
|
||||
# No PSA equivalent - needed by some init tests
|
||||
echo "MBEDTLS_ENTROPY_NV_SEED" >> $expected
|
||||
# No PSA equivalent - required to run threaded tests.
|
||||
echo "MBEDTLS_THREADING_PTHREAD" >> $expected
|
||||
|
||||
# Compare reality with expectation.
|
||||
# We want an exact match, to ensure the above list remains up-to-date.
|
||||
#
|
||||
# The output should be empty. When it's not:
|
||||
# - Each '+' line is a macro that was found but not expected. You want to
|
||||
# find where that macro occurs, and either replace it with PSA macros, or
|
||||
# add it to the exceptions list above with a justification.
|
||||
# - Each '-' line is a macro that was expected but not found; it means the
|
||||
# exceptions list above should be updated by removing that macro.
|
||||
diff -U0 $expected $found
|
||||
|
||||
rm $found $expected
|
||||
}
|
||||
|
||||
component_check_doxygen_warnings () {
|
||||
msg "Check: doxygen warnings (builds the documentation)" # ~ 3s
|
||||
tests/scripts/doxygen.sh
|
||||
}
|
||||
|
||||
component_check_code_style () {
|
||||
msg "Check C code style"
|
||||
./scripts/code_style.py
|
||||
}
|
||||
|
||||
support_check_code_style () {
|
||||
case $(uncrustify --version) in
|
||||
*0.75.1*) true;;
|
||||
*) false;;
|
||||
esac
|
||||
}
|
||||
|
||||
component_check_python_files () {
|
||||
msg "Lint: Python scripts"
|
||||
tests/scripts/check-python-files.sh
|
||||
}
|
||||
|
||||
component_check_test_helpers () {
|
||||
msg "unit test: generate_test_code.py"
|
||||
# unittest writes out mundane stuff like number or tests run on stderr.
|
||||
# Our convention is to reserve stderr for actual errors, and write
|
||||
# harmless info on stdout so it can be suppress with --quiet.
|
||||
./framework/scripts/test_generate_test_code.py 2>&1
|
||||
|
||||
msg "unit test: translate_ciphers.py"
|
||||
python3 -m unittest tests/scripts/translate_ciphers.py 2>&1
|
||||
}
|
||||
|
208
tests/scripts/components-build-system.sh
Normal file
208
tests/scripts/components-build-system.sh
Normal file
@ -0,0 +1,208 @@
|
||||
# components-build-system.sh
|
||||
#
|
||||
# Copyright The Mbed TLS Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
|
||||
# This file contains test components that are executed by all.sh
|
||||
|
||||
################################################################
|
||||
#### Build System Testing
|
||||
################################################################
|
||||
|
||||
component_test_make_shared () {
|
||||
msg "build/test: make shared" # ~ 40s
|
||||
make SHARED=1 TEST_CPP=1 all check
|
||||
ldd programs/util/strerror | grep libmbedcrypto
|
||||
programs/test/dlopen_demo.sh
|
||||
}
|
||||
|
||||
component_test_cmake_shared () {
|
||||
msg "build/test: cmake shared" # ~ 2min
|
||||
cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On .
|
||||
make
|
||||
ldd programs/util/strerror | grep libmbedcrypto
|
||||
make test
|
||||
programs/test/dlopen_demo.sh
|
||||
}
|
||||
|
||||
support_test_cmake_out_of_source () {
|
||||
distrib_id=""
|
||||
distrib_ver=""
|
||||
distrib_ver_minor=""
|
||||
distrib_ver_major=""
|
||||
|
||||
# Attempt to parse lsb-release to find out distribution and version. If not
|
||||
# found this should fail safe (test is supported).
|
||||
if [[ -f /etc/lsb-release ]]; then
|
||||
|
||||
while read -r lsb_line; do
|
||||
case "$lsb_line" in
|
||||
"DISTRIB_ID"*) distrib_id=${lsb_line/#DISTRIB_ID=};;
|
||||
"DISTRIB_RELEASE"*) distrib_ver=${lsb_line/#DISTRIB_RELEASE=};;
|
||||
esac
|
||||
done < /etc/lsb-release
|
||||
|
||||
distrib_ver_major="${distrib_ver%%.*}"
|
||||
distrib_ver="${distrib_ver#*.}"
|
||||
distrib_ver_minor="${distrib_ver%%.*}"
|
||||
fi
|
||||
|
||||
# Running the out of source CMake test on Ubuntu 16.04 using more than one
|
||||
# processor (as the CI does) can create a race condition whereby the build
|
||||
# fails to see a generated file, despite that file actually having been
|
||||
# generated. This problem appears to go away with 18.04 or newer, so make
|
||||
# the out of source tests unsupported on Ubuntu 16.04.
|
||||
[ "$distrib_id" != "Ubuntu" ] || [ "$distrib_ver_major" -gt 16 ]
|
||||
}
|
||||
|
||||
component_test_cmake_out_of_source () {
|
||||
# Remove existing generated files so that we use the ones cmake
|
||||
# generates
|
||||
make neat
|
||||
|
||||
msg "build: cmake 'out-of-source' build"
|
||||
MBEDTLS_ROOT_DIR="$PWD"
|
||||
mkdir "$OUT_OF_SOURCE_DIR"
|
||||
cd "$OUT_OF_SOURCE_DIR"
|
||||
# Note: Explicitly generate files as these are turned off in releases
|
||||
cmake -D CMAKE_BUILD_TYPE:String=Check -D GEN_FILES=ON _D TEST_CPP=1 "$MBEDTLS_ROOT_DIR"
|
||||
make
|
||||
|
||||
msg "test: cmake 'out-of-source' build"
|
||||
make test
|
||||
# Check that ssl-opt.sh can find the test programs.
|
||||
# Also ensure that there are no error messages such as
|
||||
# "No such file or directory", which would indicate that some required
|
||||
# file is missing (ssl-opt.sh tolerates the absence of some files so
|
||||
# may exit with status 0 but emit errors).
|
||||
./tests/ssl-opt.sh -f 'Default' >ssl-opt.out 2>ssl-opt.err
|
||||
grep PASS ssl-opt.out
|
||||
cat ssl-opt.err >&2
|
||||
# If ssl-opt.err is non-empty, record an error and keep going.
|
||||
[ ! -s ssl-opt.err ]
|
||||
rm ssl-opt.out ssl-opt.err
|
||||
cd "$MBEDTLS_ROOT_DIR"
|
||||
rm -rf "$OUT_OF_SOURCE_DIR"
|
||||
}
|
||||
|
||||
component_test_cmake_as_subdirectory () {
|
||||
# Remove existing generated files so that we use the ones CMake
|
||||
# generates
|
||||
make neat
|
||||
|
||||
msg "build: cmake 'as-subdirectory' build"
|
||||
cd programs/test/cmake_subproject
|
||||
# Note: Explicitly generate files as these are turned off in releases
|
||||
cmake -D GEN_FILES=ON .
|
||||
make
|
||||
./cmake_subproject
|
||||
}
|
||||
|
||||
support_test_cmake_as_subdirectory () {
|
||||
support_test_cmake_out_of_source
|
||||
}
|
||||
|
||||
component_test_cmake_as_package () {
|
||||
# Remove existing generated files so that we use the ones CMake
|
||||
# generates
|
||||
make neat
|
||||
|
||||
msg "build: cmake 'as-package' build"
|
||||
cd programs/test/cmake_package
|
||||
cmake .
|
||||
make
|
||||
./cmake_package
|
||||
}
|
||||
|
||||
support_test_cmake_as_package () {
|
||||
support_test_cmake_out_of_source
|
||||
}
|
||||
|
||||
component_test_cmake_as_package_install () {
|
||||
# Remove existing generated files so that we use the ones CMake
|
||||
# generates
|
||||
make neat
|
||||
|
||||
msg "build: cmake 'as-installed-package' build"
|
||||
cd programs/test/cmake_package_install
|
||||
cmake .
|
||||
make
|
||||
./cmake_package_install
|
||||
}
|
||||
|
||||
support_test_cmake_as_package_install () {
|
||||
support_test_cmake_out_of_source
|
||||
}
|
||||
|
||||
component_build_cmake_custom_config_file () {
|
||||
# Make a copy of config file to use for the in-tree test
|
||||
cp "$CONFIG_H" include/mbedtls_config_in_tree_copy.h
|
||||
|
||||
MBEDTLS_ROOT_DIR="$PWD"
|
||||
mkdir "$OUT_OF_SOURCE_DIR"
|
||||
cd "$OUT_OF_SOURCE_DIR"
|
||||
|
||||
# Build once to get the generated files (which need an intact config file)
|
||||
cmake "$MBEDTLS_ROOT_DIR"
|
||||
make
|
||||
|
||||
msg "build: cmake with -DMBEDTLS_CONFIG_FILE"
|
||||
scripts/config.py -w full_config.h full
|
||||
echo '#error "cmake -DMBEDTLS_CONFIG_FILE is not working."' > "$MBEDTLS_ROOT_DIR/$CONFIG_H"
|
||||
cmake -DGEN_FILES=OFF -DMBEDTLS_CONFIG_FILE=full_config.h "$MBEDTLS_ROOT_DIR"
|
||||
make
|
||||
|
||||
msg "build: cmake with -DMBEDTLS_CONFIG_FILE + -DMBEDTLS_USER_CONFIG_FILE"
|
||||
# In the user config, disable one feature (for simplicity, pick a feature
|
||||
# that nothing else depends on).
|
||||
echo '#undef MBEDTLS_NIST_KW_C' >user_config.h
|
||||
|
||||
cmake -DGEN_FILES=OFF -DMBEDTLS_CONFIG_FILE=full_config.h -DMBEDTLS_USER_CONFIG_FILE=user_config.h "$MBEDTLS_ROOT_DIR"
|
||||
make
|
||||
not programs/test/query_compile_time_config MBEDTLS_NIST_KW_C
|
||||
|
||||
rm -f user_config.h full_config.h
|
||||
|
||||
cd "$MBEDTLS_ROOT_DIR"
|
||||
rm -rf "$OUT_OF_SOURCE_DIR"
|
||||
|
||||
# Now repeat the test for an in-tree build:
|
||||
|
||||
# Restore config for the in-tree test
|
||||
mv include/mbedtls_config_in_tree_copy.h "$CONFIG_H"
|
||||
|
||||
# Build once to get the generated files (which need an intact config)
|
||||
cmake .
|
||||
make
|
||||
|
||||
msg "build: cmake (in-tree) with -DMBEDTLS_CONFIG_FILE"
|
||||
scripts/config.py -w full_config.h full
|
||||
echo '#error "cmake -DMBEDTLS_CONFIG_FILE is not working."' > "$MBEDTLS_ROOT_DIR/$CONFIG_H"
|
||||
cmake -DGEN_FILES=OFF -DMBEDTLS_CONFIG_FILE=full_config.h .
|
||||
make
|
||||
|
||||
msg "build: cmake (in-tree) with -DMBEDTLS_CONFIG_FILE + -DMBEDTLS_USER_CONFIG_FILE"
|
||||
# In the user config, disable one feature (for simplicity, pick a feature
|
||||
# that nothing else depends on).
|
||||
echo '#undef MBEDTLS_NIST_KW_C' >user_config.h
|
||||
|
||||
cmake -DGEN_FILES=OFF -DMBEDTLS_CONFIG_FILE=full_config.h -DMBEDTLS_USER_CONFIG_FILE=user_config.h .
|
||||
make
|
||||
not programs/test/query_compile_time_config MBEDTLS_NIST_KW_C
|
||||
|
||||
rm -f user_config.h full_config.h
|
||||
}
|
||||
|
||||
support_build_cmake_custom_config_file () {
|
||||
support_test_cmake_out_of_source
|
||||
}
|
||||
|
||||
component_build_cmake_programs_no_testing () {
|
||||
# Verify that the type of builds performed by oss-fuzz don't get accidentally broken
|
||||
msg "build: cmake with -DENABLE_PROGRAMS=ON and -DENABLE_TESTING=OFF"
|
||||
cmake -DENABLE_PROGRAMS=ON -DENABLE_TESTING=OFF .
|
||||
make
|
||||
}
|
||||
support_build_cmake_programs_no_testing () {
|
||||
support_test_cmake_out_of_source
|
||||
}
|
145
tests/scripts/components-compiler.sh
Normal file
145
tests/scripts/components-compiler.sh
Normal file
@ -0,0 +1,145 @@
|
||||
# components-compiler.sh
|
||||
#
|
||||
# Copyright The Mbed TLS Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
|
||||
# This file contains test components that are executed by all.sh
|
||||
|
||||
################################################################
|
||||
#### Compiler Testing
|
||||
################################################################
|
||||
|
||||
support_build_tfm_armcc () {
|
||||
support_build_armcc
|
||||
}
|
||||
|
||||
component_build_tfm_armcc () {
|
||||
# test the TF-M configuration can build cleanly with various warning flags enabled
|
||||
cp configs/config-tfm.h "$CONFIG_H"
|
||||
|
||||
msg "build: TF-M config, armclang armv7-m thumb2"
|
||||
armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m -mthumb -Os -std=c99 -Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wasm-operand-widths -Wunused -I../tests/include/spe"
|
||||
}
|
||||
|
||||
test_build_opt () {
|
||||
info=$1 cc=$2; shift 2
|
||||
$cc --version
|
||||
for opt in "$@"; do
|
||||
msg "build/test: $cc $opt, $info" # ~ 30s
|
||||
make CC="$cc" CFLAGS="$opt -std=c99 -pedantic -Wall -Wextra -Werror"
|
||||
# We're confident enough in compilers to not run _all_ the tests,
|
||||
# but at least run the unit tests. In particular, runs with
|
||||
# optimizations use inline assembly whereas runs with -O0
|
||||
# skip inline assembly.
|
||||
make test # ~30s
|
||||
make clean
|
||||
done
|
||||
}
|
||||
|
||||
# For FreeBSD we invoke the function by name so this condition is added
|
||||
# to disable the existing test_clang_opt function for linux.
|
||||
if [[ $(uname) != "Linux" ]]; then
|
||||
component_test_clang_opt () {
|
||||
scripts/config.py full
|
||||
test_build_opt 'full config' clang -O0 -Os -O2
|
||||
}
|
||||
fi
|
||||
|
||||
component_test_clang_latest_opt () {
|
||||
scripts/config.py full
|
||||
test_build_opt 'full config' "$CLANG_LATEST" -O0 -Os -O2
|
||||
}
|
||||
|
||||
support_test_clang_latest_opt () {
|
||||
type "$CLANG_LATEST" >/dev/null 2>/dev/null
|
||||
}
|
||||
|
||||
component_test_clang_earliest_opt () {
|
||||
scripts/config.py full
|
||||
test_build_opt 'full config' "$CLANG_EARLIEST" -O0
|
||||
}
|
||||
|
||||
support_test_clang_earliest_opt () {
|
||||
type "$CLANG_EARLIEST" >/dev/null 2>/dev/null
|
||||
}
|
||||
|
||||
component_test_gcc_latest_opt () {
|
||||
scripts/config.py full
|
||||
test_build_opt 'full config' "$GCC_LATEST" -O0 -Os -O2
|
||||
}
|
||||
|
||||
support_test_gcc_latest_opt () {
|
||||
type "$GCC_LATEST" >/dev/null 2>/dev/null
|
||||
}
|
||||
|
||||
component_test_gcc_earliest_opt () {
|
||||
scripts/config.py full
|
||||
test_build_opt 'full config' "$GCC_EARLIEST" -O0
|
||||
}
|
||||
|
||||
support_test_gcc_earliest_opt () {
|
||||
type "$GCC_EARLIEST" >/dev/null 2>/dev/null
|
||||
}
|
||||
|
||||
component_build_mingw () {
|
||||
msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
|
||||
make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra -maes -msse2 -mpclmul' WINDOWS_BUILD=1 lib programs
|
||||
|
||||
# note Make tests only builds the tests, but doesn't run them
|
||||
make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -maes -msse2 -mpclmul' WINDOWS_BUILD=1 tests
|
||||
make WINDOWS_BUILD=1 clean
|
||||
|
||||
msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
|
||||
make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra -maes -msse2 -mpclmul' WINDOWS_BUILD=1 SHARED=1 lib programs
|
||||
make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra -maes -msse2 -mpclmul' WINDOWS_BUILD=1 SHARED=1 tests
|
||||
make WINDOWS_BUILD=1 clean
|
||||
|
||||
msg "build: Windows cross build - mingw64, make (Library only, default config without MBEDTLS_AESNI_C)" # ~ 30s
|
||||
./scripts/config.py unset MBEDTLS_AESNI_C #
|
||||
make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib
|
||||
make WINDOWS_BUILD=1 clean
|
||||
}
|
||||
|
||||
support_build_mingw () {
|
||||
case $(i686-w64-mingw32-gcc -dumpversion 2>/dev/null) in
|
||||
[0-5]*|"") false;;
|
||||
*) true;;
|
||||
esac
|
||||
}
|
||||
|
||||
component_build_zeroize_checks () {
|
||||
msg "build: check for obviously wrong calls to mbedtls_platform_zeroize()"
|
||||
|
||||
scripts/config.py full
|
||||
|
||||
# Only compile - we're looking for sizeof-pointer-memaccess warnings
|
||||
make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-zeroize-memset.h\"' -DMBEDTLS_TEST_DEFINES_ZEROIZE -Werror -Wsizeof-pointer-memaccess"
|
||||
}
|
||||
|
||||
component_test_zeroize () {
|
||||
# Test that the function mbedtls_platform_zeroize() is not optimized away by
|
||||
# different combinations of compilers and optimization flags by using an
|
||||
# auxiliary GDB script. Unfortunately, GDB does not return error values to the
|
||||
# system in all cases that the script fails, so we must manually search the
|
||||
# output to check whether the pass string is present and no failure strings
|
||||
# were printed.
|
||||
|
||||
# Don't try to disable ASLR. We don't care about ASLR here. We do care
|
||||
# about a spurious message if Gdb tries and fails, so suppress that.
|
||||
gdb_disable_aslr=
|
||||
if [ -z "$(gdb -batch -nw -ex 'set disable-randomization off' 2>&1)" ]; then
|
||||
gdb_disable_aslr='set disable-randomization off'
|
||||
fi
|
||||
|
||||
for optimization_flag in -O2 -O3 -Ofast -Os; do
|
||||
for compiler in clang gcc; do
|
||||
msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()"
|
||||
make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag"
|
||||
gdb -ex "$gdb_disable_aslr" -x tests/scripts/test_zeroize.gdb -nw -batch -nx 2>&1 | tee test_zeroize.log
|
||||
grep "The buffer was correctly zeroized" test_zeroize.log
|
||||
not grep -i "error" test_zeroize.log
|
||||
rm -f test_zeroize.log
|
||||
make clean
|
||||
done
|
||||
done
|
||||
}
|
32
tests/scripts/components-compliance.sh
Normal file
32
tests/scripts/components-compliance.sh
Normal file
@ -0,0 +1,32 @@
|
||||
# components-compliance.sh
|
||||
#
|
||||
# Copyright The Mbed TLS Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
|
||||
# This file contains test components that are executed by all.sh
|
||||
|
||||
################################################################
|
||||
#### Compliance Testing
|
||||
################################################################
|
||||
|
||||
component_test_psa_compliance () {
|
||||
# The arch tests build with gcc, so require use of gcc here to link properly
|
||||
msg "build: make, default config (out-of-box), libmbedcrypto.a only"
|
||||
CC=gcc make -C library libmbedcrypto.a
|
||||
|
||||
msg "unit test: test_psa_compliance.py"
|
||||
CC=gcc ./tests/scripts/test_psa_compliance.py
|
||||
}
|
||||
|
||||
support_test_psa_compliance () {
|
||||
# psa-compliance-tests only supports CMake >= 3.10.0
|
||||
ver="$(cmake --version)"
|
||||
ver="${ver#cmake version }"
|
||||
ver_major="${ver%%.*}"
|
||||
|
||||
ver="${ver#*.}"
|
||||
ver_minor="${ver%%.*}"
|
||||
|
||||
[ "$ver_major" -eq 3 ] && [ "$ver_minor" -ge 10 ]
|
||||
}
|
||||
|
2666
tests/scripts/components-configuration-crypto.sh
Normal file
2666
tests/scripts/components-configuration-crypto.sh
Normal file
File diff suppressed because it is too large
Load Diff
111
tests/scripts/components-configuration-platform.sh
Normal file
111
tests/scripts/components-configuration-platform.sh
Normal file
@ -0,0 +1,111 @@
|
||||
# components-configuration-platform.sh
|
||||
#
|
||||
# Copyright The Mbed TLS Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
|
||||
# This file contains test components that are executed by all.sh
|
||||
|
||||
################################################################
|
||||
#### Configuration Testing - Platform
|
||||
################################################################
|
||||
|
||||
component_build_no_std_function () {
|
||||
# catch compile bugs in _uninit functions
|
||||
msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
|
||||
scripts/config.py full
|
||||
scripts/config.py set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
|
||||
scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
|
||||
scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
|
||||
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check .
|
||||
make
|
||||
}
|
||||
|
||||
component_build_no_sockets () {
|
||||
# Note, C99 compliance can also be tested with the sockets support disabled,
|
||||
# as that requires a POSIX platform (which isn't the same as C99).
|
||||
msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
|
||||
scripts/config.py full
|
||||
scripts/config.py unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
|
||||
scripts/config.py set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
|
||||
make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -std=c99 -pedantic' lib
|
||||
}
|
||||
|
||||
component_test_no_date_time () {
|
||||
msg "build: default config without MBEDTLS_HAVE_TIME_DATE"
|
||||
scripts/config.py unset MBEDTLS_HAVE_TIME_DATE
|
||||
cmake -D CMAKE_BUILD_TYPE:String=Check .
|
||||
make
|
||||
|
||||
msg "test: !MBEDTLS_HAVE_TIME_DATE - main suites"
|
||||
make test
|
||||
}
|
||||
|
||||
component_test_platform_calloc_macro () {
|
||||
msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
|
||||
scripts/config.py set MBEDTLS_PLATFORM_MEMORY
|
||||
scripts/config.py set MBEDTLS_PLATFORM_CALLOC_MACRO calloc
|
||||
scripts/config.py set MBEDTLS_PLATFORM_FREE_MACRO free
|
||||
CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
|
||||
make test
|
||||
}
|
||||
|
||||
component_test_have_int32 () {
|
||||
msg "build: gcc, force 32-bit bignum limbs"
|
||||
scripts/config.py unset MBEDTLS_HAVE_ASM
|
||||
scripts/config.py unset MBEDTLS_AESNI_C
|
||||
scripts/config.py unset MBEDTLS_AESCE_C
|
||||
make CC=gcc CFLAGS='-O2 -Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
|
||||
|
||||
msg "test: gcc, force 32-bit bignum limbs"
|
||||
make test
|
||||
}
|
||||
|
||||
component_test_have_int64 () {
|
||||
msg "build: gcc, force 64-bit bignum limbs"
|
||||
scripts/config.py unset MBEDTLS_HAVE_ASM
|
||||
scripts/config.py unset MBEDTLS_AESNI_C
|
||||
scripts/config.py unset MBEDTLS_AESCE_C
|
||||
make CC=gcc CFLAGS='-O2 -Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
|
||||
|
||||
msg "test: gcc, force 64-bit bignum limbs"
|
||||
make test
|
||||
}
|
||||
|
||||
component_test_have_int32_cmake_new_bignum () {
|
||||
msg "build: gcc, force 32-bit bignum limbs, new bignum interface, test hooks (ASan build)"
|
||||
scripts/config.py unset MBEDTLS_HAVE_ASM
|
||||
scripts/config.py unset MBEDTLS_AESNI_C
|
||||
scripts/config.py unset MBEDTLS_AESCE_C
|
||||
scripts/config.py set MBEDTLS_TEST_HOOKS
|
||||
scripts/config.py set MBEDTLS_ECP_WITH_MPI_UINT
|
||||
make CC=gcc CFLAGS="$ASAN_CFLAGS -Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32" LDFLAGS="$ASAN_CFLAGS"
|
||||
|
||||
msg "test: gcc, force 32-bit bignum limbs, new bignum interface, test hooks (ASan build)"
|
||||
make test
|
||||
}
|
||||
|
||||
component_test_no_udbl_division () {
|
||||
msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
|
||||
scripts/config.py full
|
||||
scripts/config.py set MBEDTLS_NO_UDBL_DIVISION
|
||||
make CFLAGS='-Werror -O1'
|
||||
|
||||
msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
|
||||
make test
|
||||
}
|
||||
|
||||
component_test_no_64bit_multiplication () {
|
||||
msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
|
||||
scripts/config.py full
|
||||
scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION
|
||||
make CFLAGS='-Werror -O1'
|
||||
|
||||
msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
|
||||
make test
|
||||
}
|
||||
|
||||
|
||||
|
575
tests/scripts/components-configuration-tls.sh
Normal file
575
tests/scripts/components-configuration-tls.sh
Normal file
@ -0,0 +1,575 @@
|
||||
# components-configuration-tls.sh
|
||||
#
|
||||
# Copyright The Mbed TLS Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
|
||||
# This file contains test components that are executed by all.sh
|
||||
|
||||
################################################################
|
||||
#### Configuration Testing - TLS
|
||||
################################################################
|
||||
|
||||
component_test_no_renegotiation () {
|
||||
msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
|
||||
scripts/config.py unset MBEDTLS_SSL_RENEGOTIATION
|
||||
CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
|
||||
make test
|
||||
|
||||
msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
component_test_tls1_2_default_stream_cipher_only () {
|
||||
msg "build: default with only stream cipher use psa"
|
||||
|
||||
scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
|
||||
scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
|
||||
# Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
|
||||
scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CCM
|
||||
scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CCM_STAR_NO_TAG
|
||||
scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_GCM
|
||||
scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CHACHA20_POLY1305
|
||||
# Note: The three unsets below are to be removed for Mbed TLS 4.0
|
||||
scripts/config.py unset MBEDTLS_GCM_C
|
||||
scripts/config.py unset MBEDTLS_CCM_C
|
||||
scripts/config.py unset MBEDTLS_CHACHAPOLY_C
|
||||
#Disable TLS 1.3 (as no AEAD)
|
||||
scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
|
||||
# Disable CBC. Note: When implemented, PSA_WANT_ALG_CBC_MAC will also need to be unset here to fully disable CBC
|
||||
scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CBC_NO_PADDING
|
||||
scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CBC_PKCS7
|
||||
# Disable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
|
||||
# Note: The unset below is to be removed for 4.0
|
||||
scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
|
||||
# Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
|
||||
scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
|
||||
# Enable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
|
||||
scripts/config.py set MBEDTLS_CIPHER_NULL_CIPHER
|
||||
# Modules that depend on AEAD
|
||||
scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
|
||||
scripts/config.py unset MBEDTLS_SSL_TICKET_C
|
||||
|
||||
make
|
||||
|
||||
msg "test: default with only stream cipher use psa"
|
||||
make test
|
||||
|
||||
# Not running ssl-opt.sh because most tests require a non-NULL ciphersuite.
|
||||
}
|
||||
|
||||
component_test_tls1_2_default_cbc_legacy_cipher_only () {
|
||||
msg "build: default with only CBC-legacy cipher use psa"
|
||||
|
||||
scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
|
||||
scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
|
||||
# Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
|
||||
scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CCM
|
||||
scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CCM_STAR_NO_TAG
|
||||
scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_GCM
|
||||
scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CHACHA20_POLY1305
|
||||
# Note: The three unsets below are to be removed for Mbed TLS 4.0
|
||||
scripts/config.py unset MBEDTLS_GCM_C
|
||||
scripts/config.py unset MBEDTLS_CCM_C
|
||||
scripts/config.py unset MBEDTLS_CHACHAPOLY_C
|
||||
#Disable TLS 1.3 (as no AEAD)
|
||||
scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
|
||||
# Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
|
||||
scripts/config.py -f $CRYPTO_CONFIG_H set PSA_WANT_ALG_CBC_NO_PADDING
|
||||
# Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
|
||||
scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
|
||||
# Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
|
||||
scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
|
||||
# Modules that depend on AEAD
|
||||
scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
|
||||
scripts/config.py unset MBEDTLS_SSL_TICKET_C
|
||||
|
||||
make
|
||||
|
||||
msg "test: default with only CBC-legacy cipher use psa"
|
||||
make test
|
||||
|
||||
msg "test: default with only CBC-legacy cipher use psa - ssl-opt.sh (subset)"
|
||||
tests/ssl-opt.sh -f "TLS 1.2"
|
||||
}
|
||||
|
||||
component_test_tls1_2_default_cbc_legacy_cbc_etm_cipher_only () {
|
||||
msg "build: default with only CBC-legacy and CBC-EtM ciphers use psa"
|
||||
|
||||
scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
|
||||
scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
|
||||
# Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
|
||||
scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CCM
|
||||
scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CCM_STAR_NO_TAG
|
||||
scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_GCM
|
||||
scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CHACHA20_POLY1305
|
||||
# Note: The three unsets below are to be removed for Mbed TLS 4.0
|
||||
scripts/config.py unset MBEDTLS_GCM_C
|
||||
scripts/config.py unset MBEDTLS_CCM_C
|
||||
scripts/config.py unset MBEDTLS_CHACHAPOLY_C
|
||||
#Disable TLS 1.3 (as no AEAD)
|
||||
scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
|
||||
# Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
|
||||
scripts/config.py -f $CRYPTO_CONFIG_H set PSA_WANT_ALG_CBC_NO_PADDING
|
||||
# Enable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
|
||||
scripts/config.py set MBEDTLS_SSL_ENCRYPT_THEN_MAC
|
||||
# Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
|
||||
scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
|
||||
# Modules that depend on AEAD
|
||||
scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
|
||||
scripts/config.py unset MBEDTLS_SSL_TICKET_C
|
||||
|
||||
make
|
||||
|
||||
msg "test: default with only CBC-legacy and CBC-EtM ciphers use psa"
|
||||
make test
|
||||
|
||||
msg "test: default with only CBC-legacy and CBC-EtM ciphers use psa - ssl-opt.sh (subset)"
|
||||
tests/ssl-opt.sh -f "TLS 1.2"
|
||||
}
|
||||
|
||||
# We're not aware of any other (open source) implementation of EC J-PAKE in TLS
|
||||
# that we could use for interop testing. However, we now have sort of two
|
||||
# implementations ourselves: one using PSA, the other not. At least test that
|
||||
# these two interoperate with each other.
|
||||
component_test_tls1_2_ecjpake_compatibility () {
|
||||
msg "build: TLS1.2 server+client w/ EC-JPAKE w/o USE_PSA"
|
||||
scripts/config.py set MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
|
||||
# Explicitly make lib first to avoid a race condition:
|
||||
# https://github.com/Mbed-TLS/mbedtls/issues/8229
|
||||
make lib
|
||||
make -C programs ssl/ssl_server2 ssl/ssl_client2
|
||||
cp programs/ssl/ssl_server2 s2_no_use_psa
|
||||
cp programs/ssl/ssl_client2 c2_no_use_psa
|
||||
|
||||
msg "build: TLS1.2 server+client w/ EC-JPAKE w/ USE_PSA"
|
||||
scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
|
||||
make clean
|
||||
make lib
|
||||
make -C programs ssl/ssl_server2 ssl/ssl_client2
|
||||
make -C programs test/udp_proxy test/query_compile_time_config
|
||||
|
||||
msg "test: server w/o USE_PSA - client w/ USE_PSA, text password"
|
||||
P_SRV=../s2_no_use_psa tests/ssl-opt.sh -f "ECJPAKE: working, TLS"
|
||||
msg "test: server w/o USE_PSA - client w/ USE_PSA, opaque password"
|
||||
P_SRV=../s2_no_use_psa tests/ssl-opt.sh -f "ECJPAKE: opaque password client only, working, TLS"
|
||||
msg "test: client w/o USE_PSA - server w/ USE_PSA, text password"
|
||||
P_CLI=../c2_no_use_psa tests/ssl-opt.sh -f "ECJPAKE: working, TLS"
|
||||
msg "test: client w/o USE_PSA - server w/ USE_PSA, opaque password"
|
||||
P_CLI=../c2_no_use_psa tests/ssl-opt.sh -f "ECJPAKE: opaque password server only, working, TLS"
|
||||
|
||||
rm s2_no_use_psa c2_no_use_psa
|
||||
}
|
||||
|
||||
component_test_small_ssl_out_content_len () {
|
||||
msg "build: small SSL_OUT_CONTENT_LEN (ASan build)"
|
||||
scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384
|
||||
scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
|
||||
CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests"
|
||||
tests/ssl-opt.sh -f "Max fragment\|Large packet"
|
||||
}
|
||||
|
||||
component_test_small_ssl_in_content_len () {
|
||||
msg "build: small SSL_IN_CONTENT_LEN (ASan build)"
|
||||
scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 4096
|
||||
scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 16384
|
||||
CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests"
|
||||
tests/ssl-opt.sh -f "Max fragment"
|
||||
}
|
||||
|
||||
component_test_small_ssl_dtls_max_buffering () {
|
||||
msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0"
|
||||
scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000
|
||||
CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test"
|
||||
tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg"
|
||||
}
|
||||
|
||||
component_test_small_mbedtls_ssl_dtls_max_buffering () {
|
||||
msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1"
|
||||
scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 190
|
||||
CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test"
|
||||
tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket"
|
||||
}
|
||||
|
||||
# Common helper for component_full_without_ecdhe_ecdsa() and
|
||||
# component_full_without_ecdhe_ecdsa_and_tls13() which:
|
||||
# - starts from the "full" configuration minus the list of symbols passed in
|
||||
# as 1st parameter
|
||||
# - build
|
||||
# - test only TLS (i.e. test_suite_tls and ssl-opt)
|
||||
build_full_minus_something_and_test_tls () {
|
||||
symbols_to_disable="$1"
|
||||
|
||||
msg "build: full minus something, test TLS"
|
||||
|
||||
scripts/config.py full
|
||||
for sym in $symbols_to_disable; do
|
||||
echo "Disabling $sym"
|
||||
scripts/config.py unset $sym
|
||||
done
|
||||
|
||||
make
|
||||
|
||||
msg "test: full minus something, test TLS"
|
||||
( cd tests; ./test_suite_ssl )
|
||||
|
||||
msg "ssl-opt: full minus something, test TLS"
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
component_full_without_ecdhe_ecdsa () {
|
||||
build_full_minus_something_and_test_tls "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED"
|
||||
}
|
||||
|
||||
component_full_without_ecdhe_ecdsa_and_tls13 () {
|
||||
build_full_minus_something_and_test_tls "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
MBEDTLS_SSL_PROTO_TLS1_3"
|
||||
}
|
||||
|
||||
component_build_no_ssl_srv () {
|
||||
msg "build: full config except SSL server, make, gcc" # ~ 30s
|
||||
scripts/config.py full
|
||||
scripts/config.py unset MBEDTLS_SSL_SRV_C
|
||||
make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1'
|
||||
}
|
||||
|
||||
component_build_no_ssl_cli () {
|
||||
msg "build: full config except SSL client, make, gcc" # ~ 30s
|
||||
scripts/config.py full
|
||||
scripts/config.py unset MBEDTLS_SSL_CLI_C
|
||||
make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1'
|
||||
}
|
||||
|
||||
component_test_no_max_fragment_length () {
|
||||
# Run max fragment length tests with MFL disabled
|
||||
msg "build: default config except MFL extension (ASan build)" # ~ 30s
|
||||
scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
|
||||
CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: ssl-opt.sh, MFL-related tests"
|
||||
tests/ssl-opt.sh -f "Max fragment length"
|
||||
}
|
||||
|
||||
component_test_asan_remove_peer_certificate () {
|
||||
msg "build: default config with MBEDTLS_SSL_KEEP_PEER_CERTIFICATE disabled (ASan build)"
|
||||
scripts/config.py unset MBEDTLS_SSL_KEEP_PEER_CERTIFICATE
|
||||
scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
|
||||
CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
|
||||
make test
|
||||
|
||||
msg "test: ssl-opt.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
|
||||
tests/ssl-opt.sh
|
||||
|
||||
msg "test: compat.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
|
||||
tests/compat.sh
|
||||
|
||||
msg "test: context-info.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
|
||||
tests/context-info.sh
|
||||
}
|
||||
|
||||
component_test_no_max_fragment_length_small_ssl_out_content_len () {
|
||||
msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)"
|
||||
scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
|
||||
scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384
|
||||
scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
|
||||
CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: MFL tests (disabled MFL extension case) & large packet tests"
|
||||
tests/ssl-opt.sh -f "Max fragment length\|Large buffer"
|
||||
|
||||
msg "test: context-info.sh (disabled MFL extension case)"
|
||||
tests/context-info.sh
|
||||
}
|
||||
|
||||
component_test_variable_ssl_in_out_buffer_len () {
|
||||
msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled (ASan build)"
|
||||
scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
|
||||
CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
|
||||
make test
|
||||
|
||||
msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
|
||||
tests/ssl-opt.sh
|
||||
|
||||
msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
|
||||
tests/compat.sh
|
||||
}
|
||||
|
||||
component_test_dtls_cid_legacy () {
|
||||
msg "build: MBEDTLS_SSL_DTLS_CONNECTION_ID (legacy) enabled (ASan build)"
|
||||
scripts/config.py set MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT 1
|
||||
|
||||
CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: MBEDTLS_SSL_DTLS_CONNECTION_ID (legacy)"
|
||||
make test
|
||||
|
||||
msg "test: ssl-opt.sh, MBEDTLS_SSL_DTLS_CONNECTION_ID (legacy) enabled"
|
||||
tests/ssl-opt.sh
|
||||
|
||||
msg "test: compat.sh, MBEDTLS_SSL_DTLS_CONNECTION_ID (legacy) enabled"
|
||||
tests/compat.sh
|
||||
}
|
||||
|
||||
component_test_ssl_alloc_buffer_and_mfl () {
|
||||
msg "build: default config with memory buffer allocator and MFL extension"
|
||||
scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||
scripts/config.py set MBEDTLS_PLATFORM_MEMORY
|
||||
scripts/config.py set MBEDTLS_MEMORY_DEBUG
|
||||
scripts/config.py set MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
|
||||
scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
|
||||
cmake -DCMAKE_BUILD_TYPE:String=Release .
|
||||
make
|
||||
|
||||
msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH"
|
||||
make test
|
||||
|
||||
msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH"
|
||||
tests/ssl-opt.sh -f "Handshake memory usage"
|
||||
}
|
||||
|
||||
component_test_when_no_ciphersuites_have_mac () {
|
||||
msg "build: when no ciphersuites have MAC"
|
||||
scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
|
||||
scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CBC_NO_PADDING
|
||||
scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CBC_PKCS7
|
||||
scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CMAC
|
||||
scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_PBKDF2_AES_CMAC_PRF_128
|
||||
|
||||
scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
|
||||
scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
|
||||
scripts/config.py unset MBEDTLS_CMAC_C
|
||||
|
||||
make
|
||||
|
||||
msg "test: !MBEDTLS_SSL_SOME_SUITES_USE_MAC"
|
||||
make test
|
||||
|
||||
msg "test ssl-opt.sh: !MBEDTLS_SSL_SOME_SUITES_USE_MAC"
|
||||
tests/ssl-opt.sh -f 'Default\|EtM' -e 'without EtM'
|
||||
}
|
||||
|
||||
component_test_tls12_only () {
|
||||
msg "build: default config without MBEDTLS_SSL_PROTO_TLS1_3, cmake, gcc, ASan"
|
||||
scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
|
||||
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: main suites (inc. selftests) (ASan build)"
|
||||
make test
|
||||
|
||||
msg "test: ssl-opt.sh (ASan build)"
|
||||
tests/ssl-opt.sh
|
||||
|
||||
msg "test: compat.sh (ASan build)"
|
||||
tests/compat.sh
|
||||
}
|
||||
|
||||
component_test_tls13_only () {
|
||||
msg "build: default config without MBEDTLS_SSL_PROTO_TLS1_2"
|
||||
scripts/config.py set MBEDTLS_SSL_EARLY_DATA
|
||||
scripts/config.py set MBEDTLS_SSL_RECORD_SIZE_LIMIT
|
||||
make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'"
|
||||
|
||||
msg "test: TLS 1.3 only, all key exchange modes enabled"
|
||||
make test
|
||||
|
||||
msg "ssl-opt.sh: TLS 1.3 only, all key exchange modes enabled"
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
component_test_tls13_only_psk () {
|
||||
msg "build: TLS 1.3 only from default, only PSK key exchange mode"
|
||||
scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
|
||||
scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED
|
||||
scripts/config.py unset MBEDTLS_ECDH_C
|
||||
scripts/config.py unset MBEDTLS_DHM_C
|
||||
scripts/config.py unset MBEDTLS_X509_CRT_PARSE_C
|
||||
scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
|
||||
scripts/config.py unset MBEDTLS_SSL_SERVER_NAME_INDICATION
|
||||
scripts/config.py unset MBEDTLS_ECDSA_C
|
||||
scripts/config.py unset MBEDTLS_PKCS1_V21
|
||||
scripts/config.py unset MBEDTLS_PKCS7_C
|
||||
scripts/config.py set MBEDTLS_SSL_EARLY_DATA
|
||||
make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'"
|
||||
|
||||
msg "test_suite_ssl: TLS 1.3 only, only PSK key exchange mode enabled"
|
||||
cd tests; ./test_suite_ssl; cd ..
|
||||
|
||||
msg "ssl-opt.sh: TLS 1.3 only, only PSK key exchange mode enabled"
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
component_test_tls13_only_ephemeral () {
|
||||
msg "build: TLS 1.3 only from default, only ephemeral key exchange mode"
|
||||
scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED
|
||||
scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED
|
||||
scripts/config.py unset MBEDTLS_SSL_EARLY_DATA
|
||||
make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'"
|
||||
|
||||
msg "test_suite_ssl: TLS 1.3 only, only ephemeral key exchange mode"
|
||||
cd tests; ./test_suite_ssl; cd ..
|
||||
|
||||
msg "ssl-opt.sh: TLS 1.3 only, only ephemeral key exchange mode"
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
component_test_tls13_only_ephemeral_ffdh () {
|
||||
msg "build: TLS 1.3 only from default, only ephemeral ffdh key exchange mode"
|
||||
scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED
|
||||
scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED
|
||||
scripts/config.py unset MBEDTLS_SSL_EARLY_DATA
|
||||
scripts/config.py unset MBEDTLS_ECDH_C
|
||||
|
||||
make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'"
|
||||
|
||||
msg "test_suite_ssl: TLS 1.3 only, only ephemeral ffdh key exchange mode"
|
||||
cd tests; ./test_suite_ssl; cd ..
|
||||
|
||||
msg "ssl-opt.sh: TLS 1.3 only, only ephemeral ffdh key exchange mode"
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
component_test_tls13_only_psk_ephemeral () {
|
||||
msg "build: TLS 1.3 only from default, only PSK ephemeral key exchange mode"
|
||||
scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED
|
||||
scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
|
||||
scripts/config.py unset MBEDTLS_X509_CRT_PARSE_C
|
||||
scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
|
||||
scripts/config.py unset MBEDTLS_SSL_SERVER_NAME_INDICATION
|
||||
scripts/config.py unset MBEDTLS_ECDSA_C
|
||||
scripts/config.py unset MBEDTLS_PKCS1_V21
|
||||
scripts/config.py unset MBEDTLS_PKCS7_C
|
||||
scripts/config.py set MBEDTLS_SSL_EARLY_DATA
|
||||
make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'"
|
||||
|
||||
msg "test_suite_ssl: TLS 1.3 only, only PSK ephemeral key exchange mode"
|
||||
cd tests; ./test_suite_ssl; cd ..
|
||||
|
||||
msg "ssl-opt.sh: TLS 1.3 only, only PSK ephemeral key exchange mode"
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
component_test_tls13_only_psk_ephemeral_ffdh () {
|
||||
msg "build: TLS 1.3 only from default, only PSK ephemeral ffdh key exchange mode"
|
||||
scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED
|
||||
scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
|
||||
scripts/config.py unset MBEDTLS_X509_CRT_PARSE_C
|
||||
scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
|
||||
scripts/config.py unset MBEDTLS_SSL_SERVER_NAME_INDICATION
|
||||
scripts/config.py unset MBEDTLS_ECDSA_C
|
||||
scripts/config.py unset MBEDTLS_PKCS1_V21
|
||||
scripts/config.py unset MBEDTLS_PKCS7_C
|
||||
scripts/config.py set MBEDTLS_SSL_EARLY_DATA
|
||||
scripts/config.py unset MBEDTLS_ECDH_C
|
||||
make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'"
|
||||
|
||||
msg "test_suite_ssl: TLS 1.3 only, only PSK ephemeral ffdh key exchange mode"
|
||||
cd tests; ./test_suite_ssl; cd ..
|
||||
|
||||
msg "ssl-opt.sh: TLS 1.3 only, only PSK ephemeral ffdh key exchange mode"
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
component_test_tls13_only_psk_all () {
|
||||
msg "build: TLS 1.3 only from default, without ephemeral key exchange mode"
|
||||
scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
|
||||
scripts/config.py unset MBEDTLS_X509_CRT_PARSE_C
|
||||
scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
|
||||
scripts/config.py unset MBEDTLS_SSL_SERVER_NAME_INDICATION
|
||||
scripts/config.py unset MBEDTLS_ECDSA_C
|
||||
scripts/config.py unset MBEDTLS_PKCS1_V21
|
||||
scripts/config.py unset MBEDTLS_PKCS7_C
|
||||
scripts/config.py set MBEDTLS_SSL_EARLY_DATA
|
||||
make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'"
|
||||
|
||||
msg "test_suite_ssl: TLS 1.3 only, PSK and PSK ephemeral key exchange modes"
|
||||
cd tests; ./test_suite_ssl; cd ..
|
||||
|
||||
msg "ssl-opt.sh: TLS 1.3 only, PSK and PSK ephemeral key exchange modes"
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
component_test_tls13_only_ephemeral_all () {
|
||||
msg "build: TLS 1.3 only from default, without PSK key exchange mode"
|
||||
scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED
|
||||
scripts/config.py set MBEDTLS_SSL_EARLY_DATA
|
||||
make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'"
|
||||
|
||||
msg "test_suite_ssl: TLS 1.3 only, ephemeral and PSK ephemeral key exchange modes"
|
||||
cd tests; ./test_suite_ssl; cd ..
|
||||
|
||||
msg "ssl-opt.sh: TLS 1.3 only, ephemeral and PSK ephemeral key exchange modes"
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
component_test_tls13_no_padding () {
|
||||
msg "build: default config plus early data minus padding"
|
||||
scripts/config.py set MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY 1
|
||||
scripts/config.py set MBEDTLS_SSL_EARLY_DATA
|
||||
CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
msg "test: default config plus early data minus padding"
|
||||
make test
|
||||
msg "ssl-opt.sh (TLS 1.3 no padding)"
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
component_test_tls13_no_compatibility_mode () {
|
||||
msg "build: default config plus early data minus middlebox compatibility mode"
|
||||
scripts/config.py unset MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE
|
||||
scripts/config.py set MBEDTLS_SSL_EARLY_DATA
|
||||
CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
msg "test: default config plus early data minus middlebox compatibility mode"
|
||||
make test
|
||||
msg "ssl-opt.sh (TLS 1.3 no compatibility mode)"
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
component_test_full_minus_session_tickets () {
|
||||
msg "build: full config without session tickets"
|
||||
scripts/config.py full
|
||||
scripts/config.py unset MBEDTLS_SSL_SESSION_TICKETS
|
||||
scripts/config.py unset MBEDTLS_SSL_EARLY_DATA
|
||||
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
msg "test: full config without session tickets"
|
||||
make test
|
||||
msg "ssl-opt.sh (full config without session tickets)"
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
component_test_depends_py_kex () {
|
||||
msg "test/build: depends.py kex (gcc)"
|
||||
tests/scripts/depends.py kex --unset-use-psa
|
||||
}
|
||||
|
||||
component_test_depends_py_kex_psa () {
|
||||
msg "test/build: depends.py kex (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
|
||||
tests/scripts/depends.py kex
|
||||
}
|
||||
|
||||
|
35
tests/scripts/components-configuration-x509.sh
Normal file
35
tests/scripts/components-configuration-x509.sh
Normal file
@ -0,0 +1,35 @@
|
||||
# components-configuration-x509.sh
|
||||
#
|
||||
# Copyright The Mbed TLS Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
|
||||
# This file contains test components that are executed by all.sh
|
||||
|
||||
################################################################
|
||||
#### Configuration Testing - X509
|
||||
################################################################
|
||||
|
||||
component_test_no_x509_info () {
|
||||
msg "build: full + MBEDTLS_X509_REMOVE_INFO" # ~ 10s
|
||||
scripts/config.pl full
|
||||
scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
|
||||
scripts/config.pl set MBEDTLS_X509_REMOVE_INFO
|
||||
make CFLAGS='-Werror -O2'
|
||||
|
||||
msg "test: full + MBEDTLS_X509_REMOVE_INFO" # ~ 10s
|
||||
make test
|
||||
|
||||
msg "test: ssl-opt.sh, full + MBEDTLS_X509_REMOVE_INFO" # ~ 1 min
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
component_test_sw_inet_pton () {
|
||||
msg "build: default plus MBEDTLS_TEST_SW_INET_PTON"
|
||||
|
||||
# MBEDTLS_TEST_HOOKS required for x509_crt_parse_cn_inet_pton
|
||||
scripts/config.py set MBEDTLS_TEST_HOOKS
|
||||
make CFLAGS="-DMBEDTLS_TEST_SW_INET_PTON"
|
||||
|
||||
msg "test: default plus MBEDTLS_TEST_SW_INET_PTON"
|
||||
make test
|
||||
}
|
397
tests/scripts/components-configuration.sh
Normal file
397
tests/scripts/components-configuration.sh
Normal file
@ -0,0 +1,397 @@
|
||||
# components-configuration.sh
|
||||
#
|
||||
# Copyright The Mbed TLS Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
|
||||
# This file contains test components that are executed by all.sh
|
||||
|
||||
################################################################
|
||||
#### Configuration Testing
|
||||
################################################################
|
||||
|
||||
component_test_default_out_of_box () {
|
||||
msg "build: make, default config (out-of-box)" # ~1min
|
||||
make
|
||||
# Disable fancy stuff
|
||||
unset MBEDTLS_TEST_OUTCOME_FILE
|
||||
|
||||
msg "test: main suites make, default config (out-of-box)" # ~10s
|
||||
make test
|
||||
|
||||
msg "selftest: make, default config (out-of-box)" # ~10s
|
||||
programs/test/selftest
|
||||
|
||||
msg "program demos: make, default config (out-of-box)" # ~10s
|
||||
tests/scripts/run_demos.py
|
||||
}
|
||||
|
||||
component_test_default_cmake_gcc_asan () {
|
||||
msg "build: cmake, gcc, ASan" # ~ 1 min 50s
|
||||
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
|
||||
make test
|
||||
|
||||
msg "program demos (ASan build)" # ~10s
|
||||
tests/scripts/run_demos.py
|
||||
|
||||
msg "test: selftest (ASan build)" # ~ 10s
|
||||
programs/test/selftest
|
||||
|
||||
msg "test: metatests (GCC, ASan build)"
|
||||
tests/scripts/run-metatests.sh any asan poison
|
||||
|
||||
msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
|
||||
tests/ssl-opt.sh
|
||||
|
||||
msg "test: compat.sh (ASan build)" # ~ 6 min
|
||||
tests/compat.sh
|
||||
|
||||
msg "test: context-info.sh (ASan build)" # ~ 15 sec
|
||||
tests/context-info.sh
|
||||
}
|
||||
|
||||
component_test_default_cmake_gcc_asan_new_bignum () {
|
||||
msg "build: cmake, gcc, ASan" # ~ 1 min 50s
|
||||
scripts/config.py set MBEDTLS_ECP_WITH_MPI_UINT
|
||||
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
|
||||
make test
|
||||
|
||||
msg "test: selftest (ASan build)" # ~ 10s
|
||||
programs/test/selftest
|
||||
|
||||
msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
|
||||
tests/ssl-opt.sh
|
||||
|
||||
msg "test: compat.sh (ASan build)" # ~ 6 min
|
||||
tests/compat.sh
|
||||
|
||||
msg "test: context-info.sh (ASan build)" # ~ 15 sec
|
||||
tests/context-info.sh
|
||||
}
|
||||
|
||||
component_test_full_cmake_gcc_asan () {
|
||||
msg "build: full config, cmake, gcc, ASan"
|
||||
scripts/config.py full
|
||||
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: main suites (inc. selftests) (full config, ASan build)"
|
||||
make test
|
||||
|
||||
msg "test: selftest (full config, ASan build)" # ~ 10s
|
||||
programs/test/selftest
|
||||
|
||||
msg "test: ssl-opt.sh (full config, ASan build)"
|
||||
tests/ssl-opt.sh
|
||||
|
||||
# Note: the next two invocations cover all compat.sh test cases.
|
||||
# We should use the same here and in basic-build-test.sh.
|
||||
msg "test: compat.sh: default version (full config, ASan build)"
|
||||
tests/compat.sh -e 'ARIA\|CHACHA'
|
||||
|
||||
msg "test: compat.sh: next: ARIA, Chacha (full config, ASan build)"
|
||||
env OPENSSL="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'
|
||||
|
||||
msg "test: context-info.sh (full config, ASan build)" # ~ 15 sec
|
||||
tests/context-info.sh
|
||||
}
|
||||
|
||||
component_test_full_cmake_gcc_asan_new_bignum () {
|
||||
msg "build: full config, cmake, gcc, ASan"
|
||||
scripts/config.py full
|
||||
scripts/config.py set MBEDTLS_ECP_WITH_MPI_UINT
|
||||
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: main suites (inc. selftests) (full config, new bignum, ASan)"
|
||||
make test
|
||||
|
||||
msg "test: selftest (full config, new bignum, ASan)" # ~ 10s
|
||||
programs/test/selftest
|
||||
|
||||
msg "test: ssl-opt.sh (full config, new bignum, ASan)"
|
||||
tests/ssl-opt.sh
|
||||
|
||||
# Note: the next two invocations cover all compat.sh test cases.
|
||||
# We should use the same here and in basic-build-test.sh.
|
||||
msg "test: compat.sh: default version (full config, new bignum, ASan)"
|
||||
tests/compat.sh -e 'ARIA\|CHACHA'
|
||||
|
||||
msg "test: compat.sh: next: ARIA, Chacha (full config, new bignum, ASan)"
|
||||
env OPENSSL="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'
|
||||
|
||||
msg "test: context-info.sh (full config, new bignum, ASan)" # ~ 15 sec
|
||||
tests/context-info.sh
|
||||
}
|
||||
|
||||
component_test_ref_configs () {
|
||||
msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
|
||||
# test-ref-configs works by overwriting mbedtls_config.h; this makes cmake
|
||||
# want to re-generate generated files that depend on it, quite correctly.
|
||||
# However this doesn't work as the generation script expects a specific
|
||||
# format for mbedtls_config.h, which the other files don't follow. Also,
|
||||
# cmake can't know this, but re-generation is actually not necessary as
|
||||
# the generated files only depend on the list of available options, not
|
||||
# whether they're on or off. So, disable cmake's (over-sensitive here)
|
||||
# dependency resolution for generated files and just rely on them being
|
||||
# present (thanks to pre_generate_files) by turning GEN_FILES off.
|
||||
CC=$ASAN_CC cmake -D GEN_FILES=Off -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
tests/scripts/test-ref-configs.pl config-tfm.h
|
||||
}
|
||||
|
||||
component_test_full_cmake_clang () {
|
||||
msg "build: cmake, full config, clang" # ~ 50s
|
||||
scripts/config.py full
|
||||
CC=clang CXX=clang cmake -D CMAKE_BUILD_TYPE:String=Release -D ENABLE_TESTING=On -D TEST_CPP=1 .
|
||||
make
|
||||
|
||||
msg "test: main suites (full config, clang)" # ~ 5s
|
||||
make test
|
||||
|
||||
msg "test: cpp_dummy_build (full config, clang)" # ~ 1s
|
||||
programs/test/cpp_dummy_build
|
||||
|
||||
msg "test: metatests (clang)"
|
||||
tests/scripts/run-metatests.sh any pthread
|
||||
|
||||
msg "program demos (full config, clang)" # ~10s
|
||||
tests/scripts/run_demos.py
|
||||
|
||||
msg "test: psa_constant_names (full config, clang)" # ~ 1s
|
||||
tests/scripts/test_psa_constant_names.py
|
||||
|
||||
msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s
|
||||
tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private'
|
||||
}
|
||||
|
||||
component_test_default_no_deprecated () {
|
||||
# Test that removing the deprecated features from the default
|
||||
# configuration leaves something consistent.
|
||||
msg "build: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 30s
|
||||
scripts/config.py set MBEDTLS_DEPRECATED_REMOVED
|
||||
make CFLAGS='-O -Werror -Wall -Wextra'
|
||||
|
||||
msg "test: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 5s
|
||||
make test
|
||||
}
|
||||
|
||||
component_test_full_no_deprecated () {
|
||||
msg "build: make, full_no_deprecated config" # ~ 30s
|
||||
scripts/config.py full_no_deprecated
|
||||
make CFLAGS='-O -Werror -Wall -Wextra'
|
||||
|
||||
msg "test: make, full_no_deprecated config" # ~ 5s
|
||||
make test
|
||||
|
||||
msg "test: ensure that X509 has no direct dependency on BIGNUM_C"
|
||||
not grep mbedtls_mpi library/libmbedx509.a
|
||||
}
|
||||
|
||||
component_test_full_no_deprecated_deprecated_warning () {
|
||||
# Test that there is nothing deprecated in "full_no_deprecated".
|
||||
# A deprecated feature would trigger a warning (made fatal) from
|
||||
# MBEDTLS_DEPRECATED_WARNING.
|
||||
msg "build: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 30s
|
||||
scripts/config.py full_no_deprecated
|
||||
scripts/config.py unset MBEDTLS_DEPRECATED_REMOVED
|
||||
scripts/config.py set MBEDTLS_DEPRECATED_WARNING
|
||||
make CFLAGS='-O -Werror -Wall -Wextra'
|
||||
|
||||
msg "test: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 5s
|
||||
make test
|
||||
}
|
||||
|
||||
component_test_full_deprecated_warning () {
|
||||
# Test that when MBEDTLS_DEPRECATED_WARNING is enabled, the build passes
|
||||
# with only certain whitelisted types of warnings.
|
||||
msg "build: make, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s
|
||||
scripts/config.py full
|
||||
scripts/config.py set MBEDTLS_DEPRECATED_WARNING
|
||||
# Expect warnings from '#warning' directives in check_config.h.
|
||||
# Note that gcc is required to allow the use of -Wno-error=cpp, which allows us to
|
||||
# display #warning messages without them being treated as errors.
|
||||
make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=cpp' lib programs
|
||||
|
||||
msg "build: make tests, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s
|
||||
# Set MBEDTLS_TEST_DEPRECATED to enable tests for deprecated features.
|
||||
# By default those are disabled when MBEDTLS_DEPRECATED_WARNING is set.
|
||||
# Expect warnings from '#warning' directives in check_config.h and
|
||||
# from the use of deprecated functions in test suites.
|
||||
make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=deprecated-declarations -Wno-error=cpp -DMBEDTLS_TEST_DEPRECATED' tests
|
||||
|
||||
msg "test: full config + MBEDTLS_TEST_DEPRECATED" # ~ 30s
|
||||
make test
|
||||
|
||||
msg "program demos: full config + MBEDTLS_TEST_DEPRECATED" # ~10s
|
||||
tests/scripts/run_demos.py
|
||||
}
|
||||
|
||||
component_build_baremetal () {
|
||||
msg "build: make, baremetal config"
|
||||
scripts/config.py baremetal
|
||||
make CFLAGS="-O1 -Werror -I$PWD/tests/include/baremetal-override/"
|
||||
}
|
||||
|
||||
support_build_baremetal () {
|
||||
# Older Glibc versions include time.h from other headers such as stdlib.h,
|
||||
# which makes the no-time.h-in-baremetal check fail. Ubuntu 16.04 has this
|
||||
# problem, Ubuntu 18.04 is ok.
|
||||
! grep -q -F time.h /usr/include/x86_64-linux-gnu/sys/types.h
|
||||
}
|
||||
|
||||
component_test_no_psa_crypto_full_cmake_asan () {
|
||||
# full minus MBEDTLS_PSA_CRYPTO_C: run the same set of tests as basic-build-test.sh
|
||||
msg "build: cmake, full config minus PSA crypto, ASan"
|
||||
scripts/config.py full
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_C
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_CLIENT
|
||||
scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
|
||||
scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
|
||||
scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
|
||||
scripts/config.py unset MBEDTLS_LMS_C
|
||||
scripts/config.py unset MBEDTLS_LMS_PRIVATE
|
||||
CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: main suites (full minus PSA crypto)"
|
||||
make test
|
||||
|
||||
# Note: ssl-opt.sh has some test cases that depend on
|
||||
# MBEDTLS_ECP_RESTARTABLE && !MBEDTLS_USE_PSA_CRYPTO
|
||||
# This is the only component where those tests are not skipped.
|
||||
msg "test: ssl-opt.sh (full minus PSA crypto)"
|
||||
tests/ssl-opt.sh
|
||||
|
||||
# Note: the next two invocations cover all compat.sh test cases.
|
||||
# We should use the same here and in basic-build-test.sh.
|
||||
msg "test: compat.sh: default version (full minus PSA crypto)"
|
||||
tests/compat.sh -e 'ARIA\|CHACHA'
|
||||
|
||||
msg "test: compat.sh: next: ARIA, Chacha (full minus PSA crypto)"
|
||||
env OPENSSL="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'
|
||||
}
|
||||
|
||||
component_build_tfm () {
|
||||
# Check that the TF-M configuration can build cleanly with various
|
||||
# warning flags enabled. We don't build or run tests, since the
|
||||
# TF-M configuration needs a TF-M platform. A tweaked version of
|
||||
# the configuration that works on mainstream platforms is in
|
||||
# configs/config-tfm.h, tested via test-ref-configs.pl.
|
||||
cp configs/config-tfm.h "$CONFIG_H"
|
||||
|
||||
msg "build: TF-M config, clang, armv7-m thumb2"
|
||||
make lib CC="clang" CFLAGS="--target=arm-linux-gnueabihf -march=armv7-m -mthumb -Os -std=c99 -Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wasm-operand-widths -Wunused -I../tests/include/spe"
|
||||
|
||||
msg "build: TF-M config, gcc native build"
|
||||
make clean
|
||||
make lib CC="gcc" CFLAGS="-Os -std=c99 -Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wformat-signedness -Wlogical-op -I../tests/include/spe"
|
||||
}
|
||||
|
||||
component_test_malloc_0_null () {
|
||||
msg "build: malloc(0) returns NULL (ASan+UBSan build)"
|
||||
scripts/config.py full
|
||||
make CC=$ASAN_CC CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"$PWD/tests/configs/user-config-malloc-0-null.h\"' $ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS"
|
||||
|
||||
msg "test: malloc(0) returns NULL (ASan+UBSan build)"
|
||||
make test
|
||||
|
||||
msg "selftest: malloc(0) returns NULL (ASan+UBSan build)"
|
||||
# Just the calloc selftest. "make test" ran the others as part of the
|
||||
# test suites.
|
||||
programs/test/selftest calloc
|
||||
|
||||
msg "test ssl-opt.sh: malloc(0) returns NULL (ASan+UBSan build)"
|
||||
# Run a subset of the tests. The choice is a balance between coverage
|
||||
# and time (including time indirectly wasted due to flaky tests).
|
||||
# The current choice is to skip tests whose description includes
|
||||
# "proxy", which is an approximation of skipping tests that use the
|
||||
# UDP proxy, which tend to be slower and flakier.
|
||||
tests/ssl-opt.sh -e 'proxy'
|
||||
}
|
||||
|
||||
component_test_no_platform () {
|
||||
# Full configuration build, without platform support, file IO and net sockets.
|
||||
# This should catch missing mbedtls_printf definitions, and by disabling file
|
||||
# IO, it should catch missing '#include <stdio.h>'
|
||||
msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
|
||||
scripts/config.py full_no_platform
|
||||
scripts/config.py unset MBEDTLS_PLATFORM_C
|
||||
scripts/config.py unset MBEDTLS_NET_C
|
||||
scripts/config.py unset MBEDTLS_FS_IO
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
|
||||
scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C
|
||||
scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
|
||||
# Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
|
||||
# to re-enable platform integration features otherwise disabled in C99 builds
|
||||
make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -Os -D_DEFAULT_SOURCE' lib programs
|
||||
make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' test
|
||||
}
|
||||
|
||||
component_build_mbedtls_config_file () {
|
||||
msg "build: make with MBEDTLS_CONFIG_FILE" # ~40s
|
||||
scripts/config.py -w full_config.h full
|
||||
echo '#error "MBEDTLS_CONFIG_FILE is not working"' >"$CONFIG_H"
|
||||
make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"'"
|
||||
# Make sure this feature is enabled. We'll disable it in the next phase.
|
||||
programs/test/query_compile_time_config MBEDTLS_NIST_KW_C
|
||||
make clean
|
||||
|
||||
msg "build: make with MBEDTLS_CONFIG_FILE + MBEDTLS_USER_CONFIG_FILE"
|
||||
# In the user config, disable one feature (for simplicity, pick a feature
|
||||
# that nothing else depends on).
|
||||
echo '#undef MBEDTLS_NIST_KW_C' >user_config.h
|
||||
make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"' -DMBEDTLS_USER_CONFIG_FILE='\"user_config.h\"'"
|
||||
not programs/test/query_compile_time_config MBEDTLS_NIST_KW_C
|
||||
|
||||
rm -f user_config.h full_config.h
|
||||
}
|
||||
|
||||
component_test_no_strings () {
|
||||
msg "build: no strings" # ~10s
|
||||
scripts/config.py full
|
||||
# Disable options that activate a large amount of string constants.
|
||||
scripts/config.py unset MBEDTLS_DEBUG_C
|
||||
scripts/config.py unset MBEDTLS_ERROR_C
|
||||
scripts/config.py set MBEDTLS_ERROR_STRERROR_DUMMY
|
||||
scripts/config.py unset MBEDTLS_VERSION_FEATURES
|
||||
make CFLAGS='-Werror -Os'
|
||||
|
||||
msg "test: no strings" # ~ 10s
|
||||
make test
|
||||
}
|
||||
|
||||
component_test_memory_buffer_allocator_backtrace () {
|
||||
msg "build: default config with memory buffer allocator and backtrace enabled"
|
||||
scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||
scripts/config.py set MBEDTLS_PLATFORM_MEMORY
|
||||
scripts/config.py set MBEDTLS_MEMORY_BACKTRACE
|
||||
scripts/config.py set MBEDTLS_MEMORY_DEBUG
|
||||
cmake -DCMAKE_BUILD_TYPE:String=Release .
|
||||
make
|
||||
|
||||
msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE"
|
||||
make test
|
||||
}
|
||||
|
||||
component_test_memory_buffer_allocator () {
|
||||
msg "build: default config with memory buffer allocator"
|
||||
scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||
scripts/config.py set MBEDTLS_PLATFORM_MEMORY
|
||||
cmake -DCMAKE_BUILD_TYPE:String=Release .
|
||||
make
|
||||
|
||||
msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C"
|
||||
make test
|
||||
|
||||
msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C"
|
||||
# MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out.
|
||||
tests/ssl-opt.sh -e '^DTLS proxy'
|
||||
}
|
503
tests/scripts/components-platform.sh
Normal file
503
tests/scripts/components-platform.sh
Normal file
@ -0,0 +1,503 @@
|
||||
# components-platform.sh
|
||||
#
|
||||
# Copyright The Mbed TLS Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
|
||||
# This file contains test components that are executed by all.sh
|
||||
|
||||
################################################################
|
||||
#### Platform Testing
|
||||
################################################################
|
||||
|
||||
component_test_m32_no_asm () {
|
||||
# Build without assembly, so as to use portable C code (in a 32-bit
|
||||
# build) and not the i386-specific inline assembly.
|
||||
#
|
||||
# Note that we require gcc, because clang Asan builds fail to link for
|
||||
# this target (cannot find libclang_rt.lsan-i386.a - this is a known clang issue).
|
||||
msg "build: i386, make, gcc, no asm (ASan build)" # ~ 30s
|
||||
scripts/config.py full
|
||||
scripts/config.py unset MBEDTLS_HAVE_ASM
|
||||
scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32
|
||||
make CC=gcc CFLAGS="$ASAN_CFLAGS -m32" LDFLAGS="-m32 $ASAN_CFLAGS"
|
||||
|
||||
msg "test: i386, make, gcc, no asm (ASan build)"
|
||||
make test
|
||||
}
|
||||
|
||||
support_test_m32_no_asm () {
|
||||
case $(uname -m) in
|
||||
amd64|x86_64) true;;
|
||||
*) false;;
|
||||
esac
|
||||
}
|
||||
|
||||
component_test_m32_o2 () {
|
||||
# Build with optimization, to use the i386 specific inline assembly
|
||||
# and go faster for tests.
|
||||
msg "build: i386, make, gcc -O2 (ASan build)" # ~ 30s
|
||||
scripts/config.py full
|
||||
scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32
|
||||
make CC=gcc CFLAGS="$ASAN_CFLAGS -m32" LDFLAGS="-m32 $ASAN_CFLAGS"
|
||||
|
||||
msg "test: i386, make, gcc -O2 (ASan build)"
|
||||
make test
|
||||
|
||||
msg "test ssl-opt.sh, i386, make, gcc-O2"
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
support_test_m32_o2 () {
|
||||
support_test_m32_no_asm "$@"
|
||||
}
|
||||
|
||||
component_test_m32_everest () {
|
||||
msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min
|
||||
scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
|
||||
scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32
|
||||
make CC=gcc CFLAGS="$ASAN_CFLAGS -m32" LDFLAGS="-m32 $ASAN_CFLAGS"
|
||||
|
||||
msg "test: i386, Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
|
||||
make test
|
||||
|
||||
msg "test: i386, Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
|
||||
tests/ssl-opt.sh -f ECDH
|
||||
|
||||
msg "test: i386, Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
|
||||
# Exclude some symmetric ciphers that are redundant here to gain time.
|
||||
tests/compat.sh -f ECDH -V NO -e 'ARIA\|CAMELLIA\|CHACHA'
|
||||
}
|
||||
|
||||
support_test_m32_everest () {
|
||||
support_test_m32_no_asm "$@"
|
||||
}
|
||||
|
||||
component_test_mx32 () {
|
||||
msg "build: 64-bit ILP32, make, gcc" # ~ 30s
|
||||
scripts/config.py full
|
||||
make CC=gcc CFLAGS='-O2 -Werror -Wall -Wextra -mx32' LDFLAGS='-mx32'
|
||||
|
||||
msg "test: 64-bit ILP32, make, gcc"
|
||||
make test
|
||||
}
|
||||
|
||||
support_test_mx32 () {
|
||||
case $(uname -m) in
|
||||
amd64|x86_64) true;;
|
||||
*) false;;
|
||||
esac
|
||||
}
|
||||
|
||||
support_test_aesni () {
|
||||
# Check that gcc targets x86_64 (we can build AESNI), and check for
|
||||
# AESNI support on the host (we can run AESNI).
|
||||
#
|
||||
# The name of this function is possibly slightly misleading, but needs to align
|
||||
# with the name of the corresponding test, component_test_aesni.
|
||||
#
|
||||
# In principle 32-bit x86 can support AESNI, but our implementation does not
|
||||
# support 32-bit x86, so we check for x86-64.
|
||||
# We can only grep /proc/cpuinfo on Linux, so this also checks for Linux
|
||||
(gcc -v 2>&1 | grep Target | grep -q x86_64) &&
|
||||
[[ "$HOSTTYPE" == "x86_64" && "$OSTYPE" == "linux-gnu" ]] &&
|
||||
(lscpu | grep -qw aes)
|
||||
}
|
||||
|
||||
component_test_aesni () { # ~ 60s
|
||||
# This tests the two AESNI implementations (intrinsics and assembly), and also the plain C
|
||||
# fallback. It also tests the logic that is used to select which implementation(s) to build.
|
||||
#
|
||||
# This test does not require the host to have support for AESNI (if it doesn't, the run-time
|
||||
# AESNI detection will fallback to the plain C implementation, so the tests will instead
|
||||
# exercise the plain C impl).
|
||||
|
||||
msg "build: default config with different AES implementations"
|
||||
scripts/config.py set MBEDTLS_AESNI_C
|
||||
scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY
|
||||
scripts/config.py set MBEDTLS_HAVE_ASM
|
||||
|
||||
# test the intrinsics implementation
|
||||
msg "AES tests, test intrinsics"
|
||||
make clean
|
||||
make CC=gcc CFLAGS='-Werror -Wall -Wextra -mpclmul -msse2 -maes'
|
||||
# check that we built intrinsics - this should be used by default when supported by the compiler
|
||||
./programs/test/selftest aes | grep "AESNI code" | grep -q "intrinsics"
|
||||
|
||||
# test the asm implementation
|
||||
msg "AES tests, test assembly"
|
||||
make clean
|
||||
make CC=gcc CFLAGS='-Werror -Wall -Wextra -mno-pclmul -mno-sse2 -mno-aes'
|
||||
# check that we built assembly - this should be built if the compiler does not support intrinsics
|
||||
./programs/test/selftest aes | grep "AESNI code" | grep -q "assembly"
|
||||
|
||||
# test the plain C implementation
|
||||
scripts/config.py unset MBEDTLS_AESNI_C
|
||||
scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY
|
||||
msg "AES tests, plain C"
|
||||
make clean
|
||||
make CC=gcc CFLAGS='-O2 -Werror'
|
||||
# check that there is no AESNI code present
|
||||
./programs/test/selftest aes | not grep -q "AESNI code"
|
||||
not grep -q "AES note: using AESNI" ./programs/test/selftest
|
||||
grep -q "AES note: built-in implementation." ./programs/test/selftest
|
||||
|
||||
# test the intrinsics implementation
|
||||
scripts/config.py set MBEDTLS_AESNI_C
|
||||
scripts/config.py set MBEDTLS_AES_USE_HARDWARE_ONLY
|
||||
msg "AES tests, test AESNI only"
|
||||
make clean
|
||||
make CC=gcc CFLAGS='-Werror -Wall -Wextra -mpclmul -msse2 -maes'
|
||||
./programs/test/selftest aes | grep -q "AES note: using AESNI"
|
||||
./programs/test/selftest aes | not grep -q "AES note: built-in implementation."
|
||||
grep -q "AES note: using AESNI" ./programs/test/selftest
|
||||
not grep -q "AES note: built-in implementation." ./programs/test/selftest
|
||||
}
|
||||
|
||||
support_test_aesni_m32 () {
|
||||
support_test_m32_no_asm && (lscpu | grep -qw aes)
|
||||
}
|
||||
|
||||
component_test_aesni_m32 () { # ~ 60s
|
||||
# This tests are duplicated from component_test_aesni for i386 target
|
||||
#
|
||||
# AESNI intrinsic code supports i386 and assembly code does not support it.
|
||||
|
||||
msg "build: default config with different AES implementations"
|
||||
scripts/config.py set MBEDTLS_AESNI_C
|
||||
scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY
|
||||
scripts/config.py set MBEDTLS_HAVE_ASM
|
||||
|
||||
# test the intrinsics implementation with gcc
|
||||
msg "AES tests, test intrinsics (gcc)"
|
||||
make clean
|
||||
make CC=gcc CFLAGS='-m32 -Werror -Wall -Wextra' LDFLAGS='-m32'
|
||||
# check that we built intrinsics - this should be used by default when supported by the compiler
|
||||
./programs/test/selftest aes | grep "AESNI code" | grep -q "intrinsics"
|
||||
grep -q "AES note: using AESNI" ./programs/test/selftest
|
||||
grep -q "AES note: built-in implementation." ./programs/test/selftest
|
||||
grep -q mbedtls_aesni_has_support ./programs/test/selftest
|
||||
|
||||
scripts/config.py set MBEDTLS_AESNI_C
|
||||
scripts/config.py set MBEDTLS_AES_USE_HARDWARE_ONLY
|
||||
msg "AES tests, test AESNI only"
|
||||
make clean
|
||||
make CC=gcc CFLAGS='-m32 -Werror -Wall -Wextra -mpclmul -msse2 -maes' LDFLAGS='-m32'
|
||||
./programs/test/selftest aes | grep -q "AES note: using AESNI"
|
||||
./programs/test/selftest aes | not grep -q "AES note: built-in implementation."
|
||||
grep -q "AES note: using AESNI" ./programs/test/selftest
|
||||
not grep -q "AES note: built-in implementation." ./programs/test/selftest
|
||||
not grep -q mbedtls_aesni_has_support ./programs/test/selftest
|
||||
}
|
||||
|
||||
support_test_aesni_m32_clang () {
|
||||
# clang >= 4 is required to build with target attributes
|
||||
support_test_aesni_m32 && [[ $(clang_version) -ge 4 ]]
|
||||
}
|
||||
|
||||
component_test_aesni_m32_clang () {
|
||||
|
||||
scripts/config.py set MBEDTLS_AESNI_C
|
||||
scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY
|
||||
scripts/config.py set MBEDTLS_HAVE_ASM
|
||||
|
||||
# test the intrinsics implementation with clang
|
||||
msg "AES tests, test intrinsics (clang)"
|
||||
make clean
|
||||
make CC=clang CFLAGS='-m32 -Werror -Wall -Wextra' LDFLAGS='-m32'
|
||||
# check that we built intrinsics - this should be used by default when supported by the compiler
|
||||
./programs/test/selftest aes | grep "AESNI code" | grep -q "intrinsics"
|
||||
grep -q "AES note: using AESNI" ./programs/test/selftest
|
||||
grep -q "AES note: built-in implementation." ./programs/test/selftest
|
||||
grep -q mbedtls_aesni_has_support ./programs/test/selftest
|
||||
}
|
||||
|
||||
support_build_aes_armce () {
|
||||
# clang >= 11 is required to build with AES extensions
|
||||
[[ $(clang_version) -ge 11 ]]
|
||||
}
|
||||
|
||||
component_build_aes_armce () {
|
||||
# Test variations of AES with Armv8 crypto extensions
|
||||
scripts/config.py set MBEDTLS_AESCE_C
|
||||
scripts/config.py set MBEDTLS_AES_USE_HARDWARE_ONLY
|
||||
|
||||
msg "MBEDTLS_AES_USE_HARDWARE_ONLY, clang, aarch64"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a+crypto"
|
||||
|
||||
msg "MBEDTLS_AES_USE_HARDWARE_ONLY, clang, arm"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm"
|
||||
|
||||
msg "MBEDTLS_AES_USE_HARDWARE_ONLY, clang, thumb"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb"
|
||||
|
||||
scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY
|
||||
|
||||
msg "no MBEDTLS_AES_USE_HARDWARE_ONLY, clang, aarch64"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a+crypto"
|
||||
|
||||
msg "no MBEDTLS_AES_USE_HARDWARE_ONLY, clang, arm"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm"
|
||||
|
||||
msg "no MBEDTLS_AES_USE_HARDWARE_ONLY, clang, thumb"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb"
|
||||
|
||||
# test for presence of AES instructions
|
||||
scripts/config.py set MBEDTLS_AES_USE_HARDWARE_ONLY
|
||||
msg "clang, test A32 crypto instructions built"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -S"
|
||||
grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.o
|
||||
msg "clang, test T32 crypto instructions built"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb -S"
|
||||
grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.o
|
||||
msg "clang, test aarch64 crypto instructions built"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a -S"
|
||||
grep -E 'aes[a-z]+\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.o
|
||||
|
||||
# test for absence of AES instructions
|
||||
scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY
|
||||
scripts/config.py unset MBEDTLS_AESCE_C
|
||||
msg "clang, test A32 crypto instructions not built"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -S"
|
||||
not grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.o
|
||||
msg "clang, test T32 crypto instructions not built"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb -S"
|
||||
not grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.o
|
||||
msg "clang, test aarch64 crypto instructions not built"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a -S"
|
||||
not grep -E 'aes[a-z]+\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.o
|
||||
}
|
||||
|
||||
support_build_sha_armce () {
|
||||
# clang >= 4 is required to build with SHA extensions
|
||||
[[ $(clang_version) -ge 4 ]]
|
||||
}
|
||||
|
||||
component_build_sha_armce () {
|
||||
scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT
|
||||
|
||||
|
||||
# Test variations of SHA256 Armv8 crypto extensions
|
||||
scripts/config.py set MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY
|
||||
msg "MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY clang, aarch64"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a"
|
||||
msg "MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY clang, arm"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm"
|
||||
scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY
|
||||
|
||||
|
||||
# test the deprecated form of the config option
|
||||
scripts/config.py set MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY
|
||||
msg "MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY clang, thumb"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb"
|
||||
scripts/config.py unset MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY
|
||||
|
||||
scripts/config.py set MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT
|
||||
msg "MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT clang, aarch64"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a"
|
||||
scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT
|
||||
|
||||
|
||||
# test the deprecated form of the config option
|
||||
scripts/config.py set MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT
|
||||
msg "MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT clang, arm"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -std=c99"
|
||||
msg "MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT clang, thumb"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb"
|
||||
scripts/config.py unset MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT
|
||||
|
||||
|
||||
# examine the disassembly for presence of SHA instructions
|
||||
for opt in MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT; do
|
||||
scripts/config.py set ${opt}
|
||||
msg "${opt} clang, test A32 crypto instructions built"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -S"
|
||||
grep -E 'sha256[a-z0-9]+.32\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.o
|
||||
|
||||
msg "${opt} clang, test T32 crypto instructions built"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb -S"
|
||||
grep -E 'sha256[a-z0-9]+.32\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.o
|
||||
|
||||
msg "${opt} clang, test aarch64 crypto instructions built"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a -S"
|
||||
grep -E 'sha256[a-z0-9]+\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.o
|
||||
scripts/config.py unset ${opt}
|
||||
done
|
||||
|
||||
|
||||
# examine the disassembly for absence of SHA instructions
|
||||
msg "clang, test A32 crypto instructions not built"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -S"
|
||||
not grep -E 'sha256[a-z0-9]+.32\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.o
|
||||
|
||||
msg "clang, test T32 crypto instructions not built"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb -S"
|
||||
not grep -E 'sha256[a-z0-9]+.32\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.o
|
||||
|
||||
msg "clang, test aarch64 crypto instructions not built"
|
||||
make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a -S"
|
||||
not grep -E 'sha256[a-z0-9]+\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.o
|
||||
}
|
||||
|
||||
component_build_arm_none_eabi_gcc () {
|
||||
msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1, baremetal+debug" # ~ 10s
|
||||
scripts/config.py baremetal
|
||||
make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra -O1' lib
|
||||
|
||||
msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1, baremetal+debug"
|
||||
${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o
|
||||
${ARM_NONE_EABI_GCC_PREFIX}size -t ${PSA_CORE_PATH}/*.o
|
||||
${ARM_NONE_EABI_GCC_PREFIX}size -t ${BUILTIN_SRC_PATH}/*.o
|
||||
}
|
||||
|
||||
component_build_arm_linux_gnueabi_gcc_arm5vte () {
|
||||
msg "build: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=arm5vte, baremetal+debug" # ~ 10s
|
||||
scripts/config.py baremetal
|
||||
# Build for a target platform that's close to what Debian uses
|
||||
# for its "armel" distribution (https://wiki.debian.org/ArmEabiPort).
|
||||
# See https://github.com/Mbed-TLS/mbedtls/pull/2169 and comments.
|
||||
# Build everything including programs, see for example
|
||||
# https://github.com/Mbed-TLS/mbedtls/pull/3449#issuecomment-675313720
|
||||
make CC="${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc" AR="${ARM_LINUX_GNUEABI_GCC_PREFIX}ar" CFLAGS='-Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te'
|
||||
|
||||
msg "size: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug"
|
||||
${ARM_LINUX_GNUEABI_GCC_PREFIX}size -t library/*.o
|
||||
${ARM_LINUX_GNUEABI_GCC_PREFIX}size -t ${PSA_CORE_PATH}/*.o
|
||||
${ARM_LINUX_GNUEABI_GCC_PREFIX}size -t ${BUILTIN_SRC_PATH}/*.o
|
||||
}
|
||||
|
||||
support_build_arm_linux_gnueabi_gcc_arm5vte () {
|
||||
type ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc >/dev/null 2>&1
|
||||
}
|
||||
|
||||
component_build_arm_none_eabi_gcc_arm5vte () {
|
||||
msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte, baremetal+debug" # ~ 10s
|
||||
scripts/config.py baremetal
|
||||
# This is an imperfect substitute for
|
||||
# component_build_arm_linux_gnueabi_gcc_arm5vte
|
||||
# in case the gcc-arm-linux-gnueabi toolchain is not available
|
||||
make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" CFLAGS='-std=c99 -Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te' SHELL='sh -x' lib
|
||||
|
||||
msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug"
|
||||
${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o
|
||||
${ARM_NONE_EABI_GCC_PREFIX}size -t ${PSA_CORE_PATH}/*.o
|
||||
${ARM_NONE_EABI_GCC_PREFIX}size -t ${BUILTIN_SRC_PATH}/*.o
|
||||
}
|
||||
|
||||
component_build_arm_none_eabi_gcc_m0plus () {
|
||||
msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus, baremetal_size" # ~ 10s
|
||||
scripts/config.py baremetal_size
|
||||
make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra -mthumb -mcpu=cortex-m0plus -Os' lib
|
||||
|
||||
msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus -Os, baremetal_size"
|
||||
${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o
|
||||
${ARM_NONE_EABI_GCC_PREFIX}size -t ${PSA_CORE_PATH}/*.o
|
||||
${ARM_NONE_EABI_GCC_PREFIX}size -t ${BUILTIN_SRC_PATH}/*.o
|
||||
for lib in library/*.a; do
|
||||
echo "$lib:"
|
||||
${ARM_NONE_EABI_GCC_PREFIX}size -t $lib | grep TOTALS
|
||||
done
|
||||
}
|
||||
|
||||
component_build_arm_none_eabi_gcc_no_udbl_division () {
|
||||
msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
|
||||
scripts/config.py baremetal
|
||||
scripts/config.py set MBEDTLS_NO_UDBL_DIVISION
|
||||
make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra' lib
|
||||
echo "Checking that software 64-bit division is not required"
|
||||
not grep __aeabi_uldiv library/*.o
|
||||
not grep __aeabi_uldiv ${PSA_CORE_PATH}/*.o
|
||||
not grep __aeabi_uldiv ${BUILTIN_SRC_PATH}/*.o
|
||||
}
|
||||
|
||||
component_build_arm_none_eabi_gcc_no_64bit_multiplication () {
|
||||
msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s
|
||||
scripts/config.py baremetal
|
||||
scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION
|
||||
make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -O1 -march=armv6-m -mthumb' lib
|
||||
echo "Checking that software 64-bit multiplication is not required"
|
||||
not grep __aeabi_lmul library/*.o
|
||||
not grep __aeabi_lmul ${PSA_CORE_PATH}/*.o
|
||||
not grep __aeabi_lmul ${BUILTIN_SRC_PATH}/*.o
|
||||
}
|
||||
|
||||
component_build_arm_clang_thumb () {
|
||||
# ~ 30s
|
||||
|
||||
scripts/config.py baremetal
|
||||
|
||||
msg "build: clang thumb 2, make"
|
||||
make clean
|
||||
make CC="clang" CFLAGS='-std=c99 -Werror -Os --target=arm-linux-gnueabihf -march=armv7-m -mthumb' lib
|
||||
|
||||
# Some Thumb 1 asm is sensitive to optimisation level, so test both -O0 and -Os
|
||||
msg "build: clang thumb 1 -O0, make"
|
||||
make clean
|
||||
make CC="clang" CFLAGS='-std=c99 -Werror -O0 --target=arm-linux-gnueabihf -mcpu=arm1136j-s -mthumb' lib
|
||||
|
||||
msg "build: clang thumb 1 -Os, make"
|
||||
make clean
|
||||
make CC="clang" CFLAGS='-std=c99 -Werror -Os --target=arm-linux-gnueabihf -mcpu=arm1136j-s -mthumb' lib
|
||||
}
|
||||
|
||||
component_build_armcc () {
|
||||
msg "build: ARM Compiler 5"
|
||||
scripts/config.py baremetal
|
||||
# armc[56] don't support SHA-512 intrinsics
|
||||
scripts/config.py unset MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT
|
||||
|
||||
# older versions of armcc/armclang don't support AESCE_C on 32-bit Arm
|
||||
scripts/config.py unset MBEDTLS_AESCE_C
|
||||
|
||||
# Stop armclang warning about feature detection for A64_CRYPTO.
|
||||
# With this enabled, the library does build correctly under armclang,
|
||||
# but in baremetal builds (as tested here), feature detection is
|
||||
# unavailable, and the user is notified via a #warning. So enabling
|
||||
# this feature would prevent us from building with -Werror on
|
||||
# armclang. Tracked in #7198.
|
||||
scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT
|
||||
|
||||
scripts/config.py set MBEDTLS_HAVE_ASM
|
||||
|
||||
make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
|
||||
|
||||
msg "size: ARM Compiler 5"
|
||||
"$ARMC5_FROMELF" -z library/*.o
|
||||
"$ARMC5_FROMELF" -z ${PSA_CORE_PATH}/*.o
|
||||
"$ARMC5_FROMELF" -z ${BUILTIN_SRC_PATH}/*.o
|
||||
|
||||
# Compile mostly with -O1 since some Arm inline assembly is disabled for -O0.
|
||||
|
||||
# ARM Compiler 6 - Target ARMv7-A
|
||||
armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv7-a"
|
||||
|
||||
# ARM Compiler 6 - Target ARMv7-M
|
||||
armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv7-m"
|
||||
|
||||
# ARM Compiler 6 - Target ARMv7-M+DSP
|
||||
armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv7-m+dsp"
|
||||
|
||||
# ARM Compiler 6 - Target ARMv8-A - AArch32
|
||||
armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv8.2-a"
|
||||
|
||||
# ARM Compiler 6 - Target ARMv8-M
|
||||
armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv8-m.main"
|
||||
|
||||
# ARM Compiler 6 - Target Cortex-M0 - no optimisation
|
||||
armc6_build_test "-O0 --target=arm-arm-none-eabi -mcpu=cortex-m0"
|
||||
|
||||
# ARM Compiler 6 - Target Cortex-M0
|
||||
armc6_build_test "-Os --target=arm-arm-none-eabi -mcpu=cortex-m0"
|
||||
|
||||
# ARM Compiler 6 - Target ARMv8.2-A - AArch64
|
||||
#
|
||||
# Re-enable MBEDTLS_AESCE_C as this should be supported by the version of armclang
|
||||
# that we have in our CI
|
||||
scripts/config.py set MBEDTLS_AESCE_C
|
||||
armc6_build_test "-O1 --target=aarch64-arm-none-eabi -march=armv8.2-a+crypto"
|
||||
}
|
||||
|
||||
support_build_armcc () {
|
||||
armc5_cc="$ARMC5_BIN_DIR/armcc"
|
||||
armc6_cc="$ARMC6_BIN_DIR/armclang"
|
||||
(check_tools "$armc5_cc" "$armc6_cc" > /dev/null 2>&1)
|
||||
}
|
99
tests/scripts/components-psasim.sh
Normal file
99
tests/scripts/components-psasim.sh
Normal file
@ -0,0 +1,99 @@
|
||||
# components-psasim.sh
|
||||
#
|
||||
# Copyright The Mbed TLS Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
|
||||
# This file contains test components that are executed by all.sh
|
||||
|
||||
################################################################
|
||||
#### Remote Procedure Call PSA Testing
|
||||
################################################################
|
||||
|
||||
# Helper function for controlling (start & stop) the psasim server.
|
||||
helper_psasim_server() {
|
||||
OPERATION=$1
|
||||
if [ "$OPERATION" == "start" ]; then
|
||||
msg "start server in tests"
|
||||
(
|
||||
cd tests
|
||||
../$PSASIM_PATH/test/start_server.sh
|
||||
)
|
||||
msg "start server in tf-psa-crypto/tests"
|
||||
(
|
||||
cd tf-psa-crypto/tests
|
||||
../../$PSASIM_PATH/test/start_server.sh
|
||||
)
|
||||
else
|
||||
msg "terminate server in tests"
|
||||
(
|
||||
# This will kill both servers and clean up all the message queues,
|
||||
# and clear temporary files in tests
|
||||
cd tests
|
||||
../$PSASIM_PATH/test/kill_servers.sh
|
||||
)
|
||||
msg "terminate server in tf-psa-crypto/tests"
|
||||
(
|
||||
# This just clears temporary files in tf-psa-crypto/tests
|
||||
cd tf-psa-crypto/tests
|
||||
../../$PSASIM_PATH/test/kill_servers.sh
|
||||
)
|
||||
fi
|
||||
}
|
||||
|
||||
component_test_psasim() {
|
||||
msg "build server library and application"
|
||||
scripts/config.py crypto
|
||||
helper_psasim_config server
|
||||
helper_psasim_build server
|
||||
|
||||
helper_psasim_cleanup_before_client
|
||||
|
||||
msg "build library for client"
|
||||
helper_psasim_config client
|
||||
helper_psasim_build client
|
||||
|
||||
msg "build basic psasim client"
|
||||
make -C $PSASIM_PATH CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS" test/psa_client_base
|
||||
msg "test basic psasim client"
|
||||
$PSASIM_PATH/test/run_test.sh psa_client_base
|
||||
|
||||
msg "build full psasim client"
|
||||
make -C $PSASIM_PATH CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS" test/psa_client_full
|
||||
msg "test full psasim client"
|
||||
$PSASIM_PATH/test/run_test.sh psa_client_full
|
||||
|
||||
helper_psasim_server kill
|
||||
make -C $PSASIM_PATH clean
|
||||
}
|
||||
|
||||
component_test_suite_with_psasim()
|
||||
{
|
||||
msg "build server library and application"
|
||||
helper_psasim_config server
|
||||
# Modify server's library configuration here (if needed)
|
||||
helper_psasim_build server
|
||||
|
||||
helper_psasim_cleanup_before_client
|
||||
|
||||
msg "build client library"
|
||||
helper_psasim_config client
|
||||
# PAKE functions are still unsupported from PSASIM
|
||||
scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_JPAKE
|
||||
scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
|
||||
helper_psasim_build client
|
||||
|
||||
msg "build test suites"
|
||||
make PSASIM=1 CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS" tests
|
||||
|
||||
helper_psasim_server start
|
||||
|
||||
# psasim takes an extremely long execution time on some test suites so we
|
||||
# exclude them from the list.
|
||||
SKIP_TEST_SUITES="constant_time_hmac,lmots,lms"
|
||||
export SKIP_TEST_SUITES
|
||||
|
||||
msg "run test suites"
|
||||
make PSASIM=1 test
|
||||
|
||||
helper_psasim_server kill
|
||||
}
|
218
tests/scripts/components-sanitizers.sh
Normal file
218
tests/scripts/components-sanitizers.sh
Normal file
@ -0,0 +1,218 @@
|
||||
# components-sanitizers.sh
|
||||
#
|
||||
# Copyright The Mbed TLS Contributors
|
||||
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
|
||||
# This file contains test components that are executed by all.sh
|
||||
|
||||
################################################################
|
||||
#### Sanitizer Testing
|
||||
################################################################
|
||||
|
||||
skip_suites_without_constant_flow () {
|
||||
# Skip the test suites that don't have any constant-flow annotations.
|
||||
# This will need to be adjusted if we ever start declaring things as
|
||||
# secret from macros or functions inside tests/include or tests/src.
|
||||
SKIP_TEST_SUITES=$(
|
||||
git -C tests/suites grep -L TEST_CF_ 'test_suite_*.function' |
|
||||
sed 's/test_suite_//; s/\.function$//' |
|
||||
tr '\n' ,),$(
|
||||
git -C tf-psa-crypto/tests/suites grep -L TEST_CF_ 'test_suite_*.function' |
|
||||
sed 's/test_suite_//; s/\.function$//' |
|
||||
tr '\n' ,)
|
||||
export SKIP_TEST_SUITES
|
||||
}
|
||||
|
||||
skip_all_except_given_suite () {
|
||||
# Skip all but the given test suite
|
||||
SKIP_TEST_SUITES=$(
|
||||
ls -1 tests/suites/test_suite_*.function |
|
||||
grep -v $1.function |
|
||||
sed 's/tests.suites.test_suite_//; s/\.function$//' |
|
||||
tr '\n' ,),$(
|
||||
ls -1 tf-psa-crypto/tests/suites/test_suite_*.function |
|
||||
grep -v $1.function |
|
||||
sed 's/tf-psa-crypto.tests.suites.test_suite_//; s/\.function$//' |
|
||||
tr '\n' ,)
|
||||
export SKIP_TEST_SUITES
|
||||
}
|
||||
|
||||
component_test_memsan_constant_flow () {
|
||||
# This tests both (1) accesses to undefined memory, and (2) branches or
|
||||
# memory access depending on secret values. To distinguish between those:
|
||||
# - unset MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN - does the failure persist?
|
||||
# - or alternatively, change the build type to MemSanDbg, which enables
|
||||
# origin tracking and nicer stack traces (which are useful for debugging
|
||||
# anyway), and check if the origin was TEST_CF_SECRET() or something else.
|
||||
msg "build: cmake MSan (clang), full config minus MBEDTLS_USE_PSA_CRYPTO with constant flow testing"
|
||||
scripts/config.py full
|
||||
scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN
|
||||
scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
|
||||
scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm
|
||||
scripts/config.py unset MBEDTLS_HAVE_ASM
|
||||
CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
|
||||
make
|
||||
|
||||
msg "test: main suites (full minus MBEDTLS_USE_PSA_CRYPTO, Msan + constant flow)"
|
||||
make test
|
||||
}
|
||||
|
||||
component_test_memsan_constant_flow_psa () {
|
||||
# This tests both (1) accesses to undefined memory, and (2) branches or
|
||||
# memory access depending on secret values. To distinguish between those:
|
||||
# - unset MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN - does the failure persist?
|
||||
# - or alternatively, change the build type to MemSanDbg, which enables
|
||||
# origin tracking and nicer stack traces (which are useful for debugging
|
||||
# anyway), and check if the origin was TEST_CF_SECRET() or something else.
|
||||
msg "build: cmake MSan (clang), full config with constant flow testing"
|
||||
scripts/config.py full
|
||||
scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN
|
||||
scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm
|
||||
scripts/config.py unset MBEDTLS_HAVE_ASM
|
||||
CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
|
||||
make
|
||||
|
||||
msg "test: main suites (Msan + constant flow)"
|
||||
make test
|
||||
}
|
||||
|
||||
component_release_test_valgrind_constant_flow () {
|
||||
# This tests both (1) everything that valgrind's memcheck usually checks
|
||||
# (heap buffer overflows, use of uninitialized memory, use-after-free,
|
||||
# etc.) and (2) branches or memory access depending on secret values,
|
||||
# which will be reported as uninitialized memory. To distinguish between
|
||||
# secret and actually uninitialized:
|
||||
# - unset MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND - does the failure persist?
|
||||
# - or alternatively, build with debug info and manually run the offending
|
||||
# test suite with valgrind --track-origins=yes, then check if the origin
|
||||
# was TEST_CF_SECRET() or something else.
|
||||
msg "build: cmake release GCC, full config minus MBEDTLS_USE_PSA_CRYPTO with constant flow testing"
|
||||
scripts/config.py full
|
||||
scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND
|
||||
scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
|
||||
skip_suites_without_constant_flow
|
||||
cmake -D CMAKE_BUILD_TYPE:String=Release .
|
||||
make
|
||||
|
||||
# this only shows a summary of the results (how many of each type)
|
||||
# details are left in Testing/<date>/DynamicAnalysis.xml
|
||||
msg "test: some suites (full minus MBEDTLS_USE_PSA_CRYPTO, valgrind + constant flow)"
|
||||
make memcheck
|
||||
|
||||
# Test asm path in constant time module - by default, it will test the plain C
|
||||
# path under Valgrind or Memsan. Running only the constant_time tests is fast (<1s)
|
||||
msg "test: valgrind asm constant_time"
|
||||
scripts/config.py --force set MBEDTLS_TEST_CONSTANT_FLOW_ASM
|
||||
skip_all_except_given_suite test_suite_constant_time
|
||||
cmake -D CMAKE_BUILD_TYPE:String=Release .
|
||||
make clean
|
||||
make
|
||||
make memcheck
|
||||
}
|
||||
|
||||
component_release_test_valgrind_constant_flow_psa () {
|
||||
# This tests both (1) everything that valgrind's memcheck usually checks
|
||||
# (heap buffer overflows, use of uninitialized memory, use-after-free,
|
||||
# etc.) and (2) branches or memory access depending on secret values,
|
||||
# which will be reported as uninitialized memory. To distinguish between
|
||||
# secret and actually uninitialized:
|
||||
# - unset MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND - does the failure persist?
|
||||
# - or alternatively, build with debug info and manually run the offending
|
||||
# test suite with valgrind --track-origins=yes, then check if the origin
|
||||
# was TEST_CF_SECRET() or something else.
|
||||
msg "build: cmake release GCC, full config with constant flow testing"
|
||||
scripts/config.py full
|
||||
scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND
|
||||
skip_suites_without_constant_flow
|
||||
cmake -D CMAKE_BUILD_TYPE:String=Release .
|
||||
make
|
||||
|
||||
# this only shows a summary of the results (how many of each type)
|
||||
# details are left in Testing/<date>/DynamicAnalysis.xml
|
||||
msg "test: some suites (valgrind + constant flow)"
|
||||
make memcheck
|
||||
}
|
||||
|
||||
component_test_tsan () {
|
||||
msg "build: TSan (clang)"
|
||||
scripts/config.py full
|
||||
scripts/config.py set MBEDTLS_THREADING_C
|
||||
scripts/config.py set MBEDTLS_THREADING_PTHREAD
|
||||
# Self-tests do not currently use multiple threads.
|
||||
scripts/config.py unset MBEDTLS_SELF_TEST
|
||||
|
||||
# The deprecated MBEDTLS_PSA_CRYPTO_SE_C interface is not thread safe.
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
|
||||
|
||||
CC=clang cmake -D CMAKE_BUILD_TYPE:String=TSan .
|
||||
make
|
||||
|
||||
msg "test: main suites (TSan)"
|
||||
make test
|
||||
}
|
||||
|
||||
component_test_memsan () {
|
||||
msg "build: MSan (clang)" # ~ 1 min 20s
|
||||
scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm
|
||||
CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
|
||||
make
|
||||
|
||||
msg "test: main suites (MSan)" # ~ 10s
|
||||
make test
|
||||
|
||||
msg "test: metatests (MSan)"
|
||||
tests/scripts/run-metatests.sh any msan
|
||||
|
||||
msg "program demos (MSan)" # ~20s
|
||||
tests/scripts/run_demos.py
|
||||
|
||||
msg "test: ssl-opt.sh (MSan)" # ~ 1 min
|
||||
tests/ssl-opt.sh
|
||||
|
||||
# Optional part(s)
|
||||
|
||||
if [ "$MEMORY" -gt 0 ]; then
|
||||
msg "test: compat.sh (MSan)" # ~ 6 min 20s
|
||||
tests/compat.sh
|
||||
fi
|
||||
}
|
||||
|
||||
component_release_test_valgrind () {
|
||||
msg "build: Release (clang)"
|
||||
# default config, in particular without MBEDTLS_USE_PSA_CRYPTO
|
||||
CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
|
||||
make
|
||||
|
||||
msg "test: main suites, Valgrind (default config)"
|
||||
make memcheck
|
||||
|
||||
# Optional parts (slow; currently broken on OS X because programs don't
|
||||
# seem to receive signals under valgrind on OS X).
|
||||
# These optional parts don't run on the CI.
|
||||
if [ "$MEMORY" -gt 0 ]; then
|
||||
msg "test: ssl-opt.sh --memcheck (default config)"
|
||||
tests/ssl-opt.sh --memcheck
|
||||
fi
|
||||
|
||||
if [ "$MEMORY" -gt 1 ]; then
|
||||
msg "test: compat.sh --memcheck (default config)"
|
||||
tests/compat.sh --memcheck
|
||||
fi
|
||||
|
||||
if [ "$MEMORY" -gt 0 ]; then
|
||||
msg "test: context-info.sh --memcheck (default config)"
|
||||
tests/context-info.sh --memcheck
|
||||
fi
|
||||
}
|
||||
|
||||
component_release_test_valgrind_psa () {
|
||||
msg "build: Release, full (clang)"
|
||||
# full config, in particular with MBEDTLS_USE_PSA_CRYPTO
|
||||
scripts/config.py full
|
||||
CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
|
||||
make
|
||||
|
||||
msg "test: main suites, Valgrind (full config)"
|
||||
make memcheck
|
||||
}
|
||||
|
@ -541,7 +541,7 @@ def main():
|
||||
default=True)
|
||||
options = parser.parse_args()
|
||||
os.chdir(options.directory)
|
||||
conf = config.ConfigFile(options.config)
|
||||
conf = config.MbedTLSConfig(options.config)
|
||||
domain_data = DomainData(options, conf)
|
||||
|
||||
if options.tasks is True:
|
||||
|
@ -20,18 +20,18 @@ from collections import namedtuple
|
||||
Certificate = namedtuple("Certificate", ['cafile', 'certfile', 'keyfile'])
|
||||
# define the certificate parameters for signature algorithms
|
||||
CERTIFICATES = {
|
||||
'ecdsa_secp256r1_sha256': Certificate('data_files/test-ca2.crt',
|
||||
'data_files/ecdsa_secp256r1.crt',
|
||||
'data_files/ecdsa_secp256r1.key'),
|
||||
'ecdsa_secp384r1_sha384': Certificate('data_files/test-ca2.crt',
|
||||
'data_files/ecdsa_secp384r1.crt',
|
||||
'data_files/ecdsa_secp384r1.key'),
|
||||
'ecdsa_secp521r1_sha512': Certificate('data_files/test-ca2.crt',
|
||||
'data_files/ecdsa_secp521r1.crt',
|
||||
'data_files/ecdsa_secp521r1.key'),
|
||||
'rsa_pss_rsae_sha256': Certificate('data_files/test-ca_cat12.crt',
|
||||
'data_files/server2-sha256.crt', 'data_files/server2.key'
|
||||
)
|
||||
'ecdsa_secp256r1_sha256': Certificate('$DATA_FILES_PATH/test-ca2.crt',
|
||||
'$DATA_FILES_PATH/ecdsa_secp256r1.crt',
|
||||
'$DATA_FILES_PATH/ecdsa_secp256r1.key'),
|
||||
'ecdsa_secp384r1_sha384': Certificate('$DATA_FILES_PATH/test-ca2.crt',
|
||||
'$DATA_FILES_PATH/ecdsa_secp384r1.crt',
|
||||
'$DATA_FILES_PATH/ecdsa_secp384r1.key'),
|
||||
'ecdsa_secp521r1_sha512': Certificate('$DATA_FILES_PATH/test-ca2.crt',
|
||||
'$DATA_FILES_PATH/ecdsa_secp521r1.crt',
|
||||
'$DATA_FILES_PATH/ecdsa_secp521r1.key'),
|
||||
'rsa_pss_rsae_sha256': Certificate('$DATA_FILES_PATH/test-ca_cat12.crt',
|
||||
'$DATA_FILES_PATH/server2-sha256.crt',
|
||||
'$DATA_FILES_PATH/server2.key')
|
||||
}
|
||||
|
||||
CIPHER_SUITE_IANA_VALUE = {
|
||||
@ -549,6 +549,9 @@ SSL_OUTPUT_HEADER = '''#!/bin/sh
|
||||
# AND REGENERATE THIS FILE.
|
||||
#
|
||||
'''
|
||||
DATA_FILES_PATH_VAR = '''
|
||||
DATA_FILES_PATH=../framework/data_files
|
||||
'''
|
||||
|
||||
def main():
|
||||
"""
|
||||
@ -628,6 +631,7 @@ def main():
|
||||
with open(args.output, 'w', encoding="utf-8") as f:
|
||||
f.write(SSL_OUTPUT_HEADER.format(
|
||||
filename=os.path.basename(args.output), cmd=' '.join(sys.argv)))
|
||||
f.write(DATA_FILES_PATH_VAR)
|
||||
f.write('\n\n'.join(get_all_test_cases()))
|
||||
f.write('\n')
|
||||
else:
|
||||
|
@ -33,7 +33,9 @@ def main():
|
||||
name_check = CodeParser(logging.getLogger())
|
||||
result = name_check.parse_identifiers([
|
||||
"include/mbedtls/*_internal.h",
|
||||
"library/*.h"
|
||||
"library/*.h",
|
||||
"tf-psa-crypto/core/*.h",
|
||||
"tf-psa-crypto/drivers/builtin/src/*.h"
|
||||
])[0]
|
||||
result.sort(key=lambda x: x.name)
|
||||
|
||||
|
@ -59,8 +59,15 @@ my $skip_re =
|
||||
')(\z|\.)' );
|
||||
|
||||
# in case test suites are linked dynamically
|
||||
$ENV{'LD_LIBRARY_PATH'} = '../library';
|
||||
$ENV{'DYLD_LIBRARY_PATH'} = '../library';
|
||||
if (-d '../../tf-psa-crypto') {
|
||||
$ENV{'LD_LIBRARY_PATH'} = '../../library';
|
||||
$ENV{'DYLD_LIBRARY_PATH'} = '../../library';
|
||||
}
|
||||
else
|
||||
{
|
||||
$ENV{'LD_LIBRARY_PATH'} = '../library';
|
||||
$ENV{'DYLD_LIBRARY_PATH'} = '../library';
|
||||
}
|
||||
|
||||
my $prefix = $^O eq "MSWin32" ? '' : './';
|
||||
|
||||
|
@ -39,7 +39,14 @@ def main(library_build_dir: str):
|
||||
in_tf_psa_crypto_repo = build_tree.looks_like_tf_psa_crypto_root(root_dir)
|
||||
|
||||
crypto_name = build_tree.crypto_library_filename(root_dir)
|
||||
library_subdir = build_tree.crypto_core_directory(root_dir, relative=True)
|
||||
|
||||
# Temporary, while the crypto library is still located in the library
|
||||
# directory. This will not be the case anymore when it will be built by
|
||||
# the TF-PSA-Crypto build system.
|
||||
if in_tf_psa_crypto_repo:
|
||||
library_subdir = build_tree.crypto_core_directory(root_dir, relative=True)
|
||||
else:
|
||||
library_subdir = 'library'
|
||||
|
||||
crypto_lib_filename = (library_build_dir + '/' +
|
||||
library_subdir + '/' +
|
||||
|
@ -156,7 +156,7 @@ class Tests:
|
||||
out.write(' PASS\n')
|
||||
|
||||
HEADERS = ['psa/crypto.h', 'psa/crypto_extra.h', 'psa/crypto_values.h']
|
||||
TEST_SUITES = ['tests/suites/test_suite_psa_crypto_metadata.data']
|
||||
TEST_SUITES = ['tf-psa-crypto/tests/suites/test_suite_psa_crypto_metadata.data']
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=globals()['__doc__'])
|
||||
|
Reference in New Issue
Block a user