mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-07 06:42:56 +03:00
Merge remote-tracking branch 'development' into psa_crypto_config-in-full
Conflicts: * tests/scripts/all.sh: component_test_crypto_full_no_cipher was removed in the development branch.
This commit is contained in:
@@ -176,7 +176,10 @@ pre_initialize_variables () {
|
||||
: ${ARMC6_BIN_DIR:=/usr/bin}
|
||||
: ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-}
|
||||
: ${ARM_LINUX_GNUEABI_GCC_PREFIX:=arm-linux-gnueabi-}
|
||||
|
||||
: ${CLANG_LATEST:="clang-latest"}
|
||||
: ${CLANG_EARLIEST:="clang-earliest"}
|
||||
: ${GCC_LATEST:="gcc-latest"}
|
||||
: ${GCC_EARLIEST:="gcc-earliest"}
|
||||
# if MAKEFLAGS is not set add the -j option to speed up invocations of make
|
||||
if [ -z "${MAKEFLAGS+set}" ]; then
|
||||
export MAKEFLAGS="-j$(all_sh_nproc)"
|
||||
@@ -191,9 +194,7 @@ pre_initialize_variables () {
|
||||
|
||||
# Gather the list of available components. These are the functions
|
||||
# defined in this script whose name starts with "component_".
|
||||
# Parse the script with sed. This way we get the functions in the order
|
||||
# they are defined.
|
||||
ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0")
|
||||
ALL_COMPONENTS=$(compgen -A function component_ | sed 's/component_//')
|
||||
|
||||
# Exclude components that are not supported on this platform.
|
||||
SUPPORTED_COMPONENTS=
|
||||
@@ -275,6 +276,10 @@ General options:
|
||||
Tool path options:
|
||||
--armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
|
||||
--armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
|
||||
--clang-earliest=<Clang_earliest_path> Earliest version of clang available
|
||||
--clang-latest=<Clang_latest_path> Latest version of clang available
|
||||
--gcc-earliest=<GCC_earliest_path> Earliest version of GCC available
|
||||
--gcc-latest=<GCC_latest_path> Latest version of GCC available
|
||||
--gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
|
||||
--gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
|
||||
--gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
|
||||
@@ -441,9 +446,13 @@ pre_parse_command_line () {
|
||||
--armcc) no_armcc=;;
|
||||
--armc5-bin-dir) shift; ;; # assignment to ARMC5_BIN_DIR done in pre_parse_command_line_for_dirs
|
||||
--armc6-bin-dir) shift; ;; # assignment to ARMC6_BIN_DIR done in pre_parse_command_line_for_dirs
|
||||
--clang-earliest) shift; CLANG_EARLIEST="$1";;
|
||||
--clang-latest) shift; CLANG_LATEST="$1";;
|
||||
--error-test) error_test=$((error_test + 1));;
|
||||
--except) all_except=1;;
|
||||
--force|-f) FORCE=1;;
|
||||
--gcc-earliest) shift; GCC_EARLIEST="$1";;
|
||||
--gcc-latest) shift; GCC_LATEST="$1";;
|
||||
--gnutls-cli) shift; GNUTLS_CLI="$1";;
|
||||
--gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";;
|
||||
--gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";;
|
||||
@@ -1028,8 +1037,9 @@ component_test_default_cmake_gcc_asan () {
|
||||
|
||||
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 CFLAGS="-D MBEDTLS_ECP_WITH_MPI_UINT"
|
||||
make
|
||||
|
||||
msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
|
||||
make test
|
||||
@@ -1086,8 +1096,9 @@ component_test_full_cmake_gcc_asan () {
|
||||
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 CFLAGS="-D MBEDTLS_ECP_WITH_MPI_UINT"
|
||||
make
|
||||
|
||||
msg "test: main suites (inc. selftests) (full config, ASan build)"
|
||||
make test
|
||||
@@ -1122,8 +1133,9 @@ component_test_full_cmake_gcc_asan_new_bignum_test_hooks () {
|
||||
msg "build: full config, cmake, gcc, ASan"
|
||||
scripts/config.py full
|
||||
scripts/config.py set MBEDTLS_TEST_HOOKS
|
||||
scripts/config.py set MBEDTLS_ECP_WITH_MPI_UINT
|
||||
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make CFLAGS="-DMBEDTLS_ECP_WITH_MPI_UINT"
|
||||
make
|
||||
|
||||
msg "test: main suites (inc. selftests) (full config, ASan build)"
|
||||
make test
|
||||
@@ -1499,33 +1511,6 @@ component_test_full_no_cipher () {
|
||||
make test
|
||||
}
|
||||
|
||||
component_test_crypto_full_no_cipher () {
|
||||
msg "build: crypto_full minus CIPHER"
|
||||
scripts/config.py crypto_full
|
||||
scripts/config.py unset MBEDTLS_CIPHER_C
|
||||
# Don't pull in cipher via PSA mechanisms
|
||||
# (currently ignored anyway because we completely disable PSA)
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_CONFIG
|
||||
# Direct dependencies
|
||||
scripts/config.py unset MBEDTLS_CCM_C
|
||||
scripts/config.py unset MBEDTLS_CMAC_C
|
||||
scripts/config.py unset MBEDTLS_GCM_C
|
||||
scripts/config.py unset MBEDTLS_NIST_KW_C
|
||||
scripts/config.py unset MBEDTLS_PKCS12_C
|
||||
scripts/config.py unset MBEDTLS_PKCS5_C
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_C
|
||||
# Indirect dependencies
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
|
||||
scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
|
||||
scripts/config.py unset MBEDTLS_LMS_C
|
||||
scripts/config.py unset MBEDTLS_LMS_PRIVATE
|
||||
make
|
||||
|
||||
msg "test: crypto_full minus CIPHER"
|
||||
make test
|
||||
}
|
||||
|
||||
component_test_full_no_bignum () {
|
||||
msg "build: full minus bignum"
|
||||
scripts/config.py full
|
||||
@@ -1791,9 +1776,7 @@ component_test_everest_curve25519_only () {
|
||||
scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
scripts/config.py unset MBEDTLS_ECJPAKE_C
|
||||
# Disable all curves
|
||||
for c in $(sed -n 's/#define \(MBEDTLS_ECP_DP_[0-9A-Z_a-z]*_ENABLED\).*/\1/p' <"$CONFIG_H"); do
|
||||
scripts/config.py unset "$c"
|
||||
done
|
||||
scripts/config.py unset-all "MBEDTLS_ECP_DP_[0-9A-Z_a-z]*_ENABLED"
|
||||
scripts/config.py set MBEDTLS_ECP_DP_CURVE25519_ENABLED
|
||||
|
||||
make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
|
||||
@@ -2358,7 +2341,12 @@ component_test_psa_crypto_config_accel_ffdh () {
|
||||
msg "build: full with accelerated FFDH"
|
||||
|
||||
# Algorithms and key types to accelerate
|
||||
loc_accel_list="ALG_FFDH KEY_TYPE_DH_KEY_PAIR KEY_TYPE_DH_PUBLIC_KEY"
|
||||
loc_accel_list="ALG_FFDH \
|
||||
KEY_TYPE_DH_KEY_PAIR_BASIC \
|
||||
KEY_TYPE_DH_KEY_PAIR_IMPORT \
|
||||
KEY_TYPE_DH_KEY_PAIR_EXPORT \
|
||||
KEY_TYPE_DH_KEY_PAIR_GENERATE \
|
||||
KEY_TYPE_DH_PUBLIC_KEY"
|
||||
|
||||
# Configure
|
||||
# ---------
|
||||
@@ -2549,8 +2537,6 @@ config_psa_crypto_no_ecp_at_all () {
|
||||
# start with full config for maximum coverage (also enables USE_PSA)
|
||||
helper_libtestdriver1_adjust_config "full"
|
||||
|
||||
# enable support for drivers and configuring PSA-only algorithms
|
||||
scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
|
||||
if [ "$DRIVER_ONLY" -eq 1 ]; then
|
||||
# Disable modules that are accelerated
|
||||
scripts/config.py unset MBEDTLS_ECDSA_C
|
||||
@@ -2640,6 +2626,138 @@ component_test_psa_crypto_config_reference_ecc_no_ecp_at_all () {
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
# This function is really similar to config_psa_crypto_no_ecp_at_all() above so
|
||||
# its description is basically the same. The main difference in this case is
|
||||
# that when the EC built-in implementation is disabled, then also Bignum module
|
||||
# and its dependencies are disabled as well.
|
||||
#
|
||||
# This is the common helper between:
|
||||
# - component_test_psa_crypto_config_accel_ecc_no_bignum
|
||||
# - component_test_psa_crypto_config_reference_ecc_no_bignum
|
||||
config_psa_crypto_config_accel_ecc_no_bignum() {
|
||||
DRIVER_ONLY="$1"
|
||||
# start with full config for maximum coverage (also enables USE_PSA)
|
||||
helper_libtestdriver1_adjust_config "full"
|
||||
|
||||
if [ "$DRIVER_ONLY" -eq 1 ]; then
|
||||
# Disable modules that are accelerated
|
||||
scripts/config.py unset MBEDTLS_ECDSA_C
|
||||
scripts/config.py unset MBEDTLS_ECDH_C
|
||||
scripts/config.py unset MBEDTLS_ECJPAKE_C
|
||||
# Disable ECP module (entirely)
|
||||
scripts/config.py unset MBEDTLS_ECP_C
|
||||
# Also disable bignum
|
||||
scripts/config.py unset MBEDTLS_BIGNUM_C
|
||||
fi
|
||||
|
||||
# Disable all the features that auto-enable ECP_LIGHT (see build_info.h)
|
||||
scripts/config.py unset MBEDTLS_PK_PARSE_EC_EXTENDED
|
||||
scripts/config.py unset MBEDTLS_PK_PARSE_EC_COMPRESSED
|
||||
scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE
|
||||
|
||||
# RSA support is intentionally disabled on this test because RSA_C depends
|
||||
# on BIGNUM_C.
|
||||
scripts/config.py -f "$CRYPTO_CONFIG_H" unset-all "PSA_WANT_KEY_TYPE_RSA_[0-9A-Z_a-z]*"
|
||||
scripts/config.py -f "$CRYPTO_CONFIG_H" unset-all "PSA_WANT_ALG_RSA_[0-9A-Z_a-z]*"
|
||||
scripts/config.py unset MBEDTLS_RSA_C
|
||||
scripts/config.py unset MBEDTLS_PKCS1_V15
|
||||
scripts/config.py unset MBEDTLS_PKCS1_V21
|
||||
scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
|
||||
# Also disable key exchanges that depend on RSA
|
||||
scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
|
||||
scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
|
||||
scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
|
||||
scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
|
||||
scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
|
||||
|
||||
# Disable FFDH because it also depends on BIGNUM.
|
||||
scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_FFDH
|
||||
scripts/config.py -f "$CRYPTO_CONFIG_H" unset-all "PSA_WANT_KEY_TYPE_DH_[0-9A-Z_a-z]*"
|
||||
scripts/config.py unset MBEDTLS_DHM_C
|
||||
# Also disable key exchanges that depend on FFDH
|
||||
scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED
|
||||
scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
|
||||
|
||||
# Restartable feature is not yet supported by PSA. Once it will in
|
||||
# the future, the following line could be removed (see issues
|
||||
# 6061, 6332 and following ones)
|
||||
scripts/config.py unset MBEDTLS_ECP_RESTARTABLE
|
||||
}
|
||||
|
||||
# Build and test a configuration where driver accelerates all EC algs while
|
||||
# all support and dependencies from ECP and ECP_LIGHT are removed on the library
|
||||
# side.
|
||||
#
|
||||
# Keep in sync with component_test_psa_crypto_config_reference_ecc_no_bignum()
|
||||
component_test_psa_crypto_config_accel_ecc_no_bignum () {
|
||||
msg "build: full + accelerated EC algs + USE_PSA - ECP - BIGNUM"
|
||||
|
||||
# Algorithms and key types to accelerate
|
||||
loc_accel_list="ALG_ECDSA ALG_DETERMINISTIC_ECDSA \
|
||||
ALG_ECDH \
|
||||
ALG_JPAKE \
|
||||
KEY_TYPE_ECC_KEY_PAIR_BASIC \
|
||||
KEY_TYPE_ECC_KEY_PAIR_IMPORT \
|
||||
KEY_TYPE_ECC_KEY_PAIR_EXPORT \
|
||||
KEY_TYPE_ECC_KEY_PAIR_GENERATE \
|
||||
KEY_TYPE_ECC_PUBLIC_KEY"
|
||||
|
||||
# Configure
|
||||
# ---------
|
||||
|
||||
# Set common configurations between library's and driver's builds
|
||||
config_psa_crypto_config_accel_ecc_no_bignum 1
|
||||
|
||||
# Build
|
||||
# -----
|
||||
|
||||
# Things we wanted supported in libtestdriver1, but not accelerated in the main library:
|
||||
# SHA-1 and all SHA-2 variants, as they are used by ECDSA deterministic.
|
||||
loc_extra_list="ALG_SHA_1 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512"
|
||||
|
||||
helper_libtestdriver1_make_drivers "$loc_accel_list" "$loc_extra_list"
|
||||
|
||||
helper_libtestdriver1_make_main "$loc_accel_list"
|
||||
|
||||
# Make sure any built-in EC alg was not re-enabled by accident (additive config)
|
||||
not grep mbedtls_ecdsa_ library/ecdsa.o
|
||||
not grep mbedtls_ecdh_ library/ecdh.o
|
||||
not grep mbedtls_ecjpake_ library/ecjpake.o
|
||||
# Also ensure that ECP, RSA, DHM or BIGNUM modules were not re-enabled
|
||||
not grep mbedtls_ecp_ library/ecp.o
|
||||
not grep mbedtls_rsa_ library/rsa.o
|
||||
not grep mbedtls_dhm_ library/dhm.o
|
||||
not grep mbedtls_mpi_ library/bignum.o
|
||||
|
||||
# Run the tests
|
||||
# -------------
|
||||
|
||||
msg "test suites: full + accelerated EC algs + USE_PSA - ECP - BIGNUM"
|
||||
make test
|
||||
|
||||
# The following will be enabled in #7756
|
||||
msg "ssl-opt: full + accelerated EC algs + USE_PSA - ECP - BIGNUM"
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
# Reference function used for driver's coverage analysis in analyze_outcomes.py
|
||||
# in conjunction with component_test_psa_crypto_config_accel_ecc_no_bignum().
|
||||
# Keep in sync with its accelerated counterpart.
|
||||
component_test_psa_crypto_config_reference_ecc_no_bignum () {
|
||||
msg "build: full + non accelerated EC algs + USE_PSA"
|
||||
|
||||
config_psa_crypto_config_accel_ecc_no_bignum 0
|
||||
|
||||
make
|
||||
|
||||
msg "test suites: full + non accelerated EC algs + USE_PSA"
|
||||
make test
|
||||
|
||||
# The following will be enabled in #7756
|
||||
msg "ssl-opt: full + non accelerated EC algs + USE_PSA"
|
||||
tests/ssl-opt.sh
|
||||
}
|
||||
|
||||
# Helper function used in:
|
||||
# - component_test_psa_crypto_config_accel_all_curves_except_p192
|
||||
# - component_test_psa_crypto_config_accel_all_curves_except_x25519
|
||||
@@ -2681,14 +2799,8 @@ psa_crypto_config_accel_all_curves_except_one () {
|
||||
scripts/config.py unset MBEDTLS_PKCS1_V21
|
||||
scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
|
||||
# Disable RSA on the PSA side too
|
||||
scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC
|
||||
scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT
|
||||
scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT
|
||||
scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE
|
||||
scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY
|
||||
for ALG in $(sed -n 's/^#define \(PSA_WANT_ALG_RSA_[0-9A-Z_a-z]*\).*/\1/p' <"$CRYPTO_CONFIG_H"); do
|
||||
scripts/config.py -f "$CRYPTO_CONFIG_H" unset $ALG
|
||||
done
|
||||
scripts/config.py -f "$CRYPTO_CONFIG_H" unset-all "PSA_WANT_KEY_TYPE_RSA_[0-9A-Z_a-z]*"
|
||||
scripts/config.py -f "$CRYPTO_CONFIG_H" unset-all "PSA_WANT_ALG_RSA_[0-9A-Z_a-z]*"
|
||||
# Also disable key exchanges that depend on RSA
|
||||
scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
|
||||
scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
|
||||
@@ -2697,9 +2809,7 @@ psa_crypto_config_accel_all_curves_except_one () {
|
||||
scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
|
||||
|
||||
# Explicitly disable all SW implementation for elliptic curves
|
||||
for CURVE in $(sed -n 's/#define \(MBEDTLS_ECP_DP_[0-9A-Z_a-z]*_ENABLED\).*/\1/p' <"$CONFIG_H"); do
|
||||
scripts/config.py unset "$CURVE"
|
||||
done
|
||||
scripts/config.py unset-all "MBEDTLS_ECP_DP_[0-9A-Z_a-z]*_ENABLED"
|
||||
# Just leave SW implementation for the specified curve for allowing to
|
||||
# build with ECP_C.
|
||||
scripts/config.py set $BUILTIN_CURVE
|
||||
@@ -3968,6 +4078,7 @@ component_test_cmake_shared () {
|
||||
|
||||
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"
|
||||
@@ -3980,14 +4091,45 @@ test_build_opt () {
|
||||
done
|
||||
}
|
||||
|
||||
component_test_clang_opt () {
|
||||
# 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 -O0 -Os -O2
|
||||
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_gcc_opt () {
|
||||
component_test_clang_earliest_opt () {
|
||||
scripts/config.py full
|
||||
test_build_opt 'full config' gcc -O0 -Os -O2
|
||||
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_mbedtls_config_file () {
|
||||
@@ -4153,6 +4295,20 @@ component_test_have_int64 () {
|
||||
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_PADLOCK_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
|
||||
|
@@ -310,6 +310,99 @@ TASKS = {
|
||||
}
|
||||
}
|
||||
},
|
||||
'analyze_driver_vs_reference_no_bignum': {
|
||||
'test_function': do_analyze_driver_vs_reference,
|
||||
'args': {
|
||||
'component_ref': 'test_psa_crypto_config_reference_ecc_no_bignum',
|
||||
'component_driver': 'test_psa_crypto_config_accel_ecc_no_bignum',
|
||||
'ignored_suites': [
|
||||
# Ignore test suites for the modules that are disabled in the
|
||||
# accelerated test case.
|
||||
'ecp',
|
||||
'ecdsa',
|
||||
'ecdh',
|
||||
'ecjpake',
|
||||
'bignum_core',
|
||||
'bignum_random',
|
||||
'bignum_mod',
|
||||
'bignum_mod_raw',
|
||||
'bignum.generated',
|
||||
'bignum.misc',
|
||||
],
|
||||
'ignored_tests': {
|
||||
'test_suite_random': [
|
||||
'PSA classic wrapper: ECDSA signature (SECP256R1)',
|
||||
],
|
||||
'test_suite_psa_crypto': [
|
||||
'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1',
|
||||
'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1 (1 redraw)',
|
||||
'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1, exercise ECDSA',
|
||||
'PSA key derivation: HKDF-SHA-256 -> ECC secp384r1',
|
||||
'PSA key derivation: HKDF-SHA-256 -> ECC secp521r1 #0',
|
||||
'PSA key derivation: HKDF-SHA-256 -> ECC secp521r1 #1',
|
||||
'PSA key derivation: bits=7 invalid for ECC BRAINPOOL_P_R1 (ECC enabled)',
|
||||
'PSA key derivation: bits=7 invalid for ECC SECP_K1 (ECC enabled)',
|
||||
'PSA key derivation: bits=7 invalid for ECC SECP_R1 (ECC enabled)',
|
||||
'PSA key derivation: bits=7 invalid for ECC SECP_R2 (ECC enabled)',
|
||||
'PSA key derivation: bits=7 invalid for ECC SECT_K1 (ECC enabled)',
|
||||
'PSA key derivation: bits=7 invalid for ECC SECT_R1 (ECC enabled)',
|
||||
'PSA key derivation: bits=7 invalid for ECC SECT_R2 (ECC enabled)',
|
||||
],
|
||||
'test_suite_pkparse': [
|
||||
# See the description provided above in the
|
||||
# analyze_driver_vs_reference_no_ecp_at_all component.
|
||||
'Parse EC Key #10a (SEC1 PEM, secp384r1, compressed)',
|
||||
'Parse EC Key #11a (SEC1 PEM, secp521r1, compressed)',
|
||||
'Parse EC Key #12a (SEC1 PEM, bp256r1, compressed)',
|
||||
'Parse EC Key #13a (SEC1 PEM, bp384r1, compressed)',
|
||||
'Parse EC Key #14a (SEC1 PEM, bp512r1, compressed)',
|
||||
'Parse EC Key #2a (SEC1 PEM, secp192r1, compressed)',
|
||||
'Parse EC Key #8a (SEC1 PEM, secp224r1, compressed)',
|
||||
'Parse EC Key #9a (SEC1 PEM, secp256r1, compressed)',
|
||||
'Parse Public EC Key #2a (RFC 5480, PEM, secp192r1, compressed)',
|
||||
'Parse Public EC Key #3a (RFC 5480, secp224r1, compressed)',
|
||||
'Parse Public EC Key #4a (RFC 5480, secp256r1, compressed)',
|
||||
'Parse Public EC Key #5a (RFC 5480, secp384r1, compressed)',
|
||||
'Parse Public EC Key #6a (RFC 5480, secp521r1, compressed)',
|
||||
'Parse Public EC Key #7a (RFC 5480, brainpoolP256r1, compressed)',
|
||||
'Parse Public EC Key #8a (RFC 5480, brainpoolP384r1, compressed)',
|
||||
'Parse Public EC Key #9a (RFC 5480, brainpoolP512r1, compressed)',
|
||||
],
|
||||
'test_suite_asn1parse': [
|
||||
# This test depends on BIGNUM_C
|
||||
'INTEGER too large for mpi',
|
||||
],
|
||||
'test_suite_asn1write': [
|
||||
# Following tests depends on BIGNUM_C
|
||||
'ASN.1 Write mpi 0 (1 limb)',
|
||||
'ASN.1 Write mpi 0 (null)',
|
||||
'ASN.1 Write mpi 0x100',
|
||||
'ASN.1 Write mpi 0x7f',
|
||||
'ASN.1 Write mpi 0x7f with leading 0 limb',
|
||||
'ASN.1 Write mpi 0x80',
|
||||
'ASN.1 Write mpi 0x80 with leading 0 limb',
|
||||
'ASN.1 Write mpi 0xff',
|
||||
'ASN.1 Write mpi 1',
|
||||
'ASN.1 Write mpi, 127*8 bits',
|
||||
'ASN.1 Write mpi, 127*8+1 bits',
|
||||
'ASN.1 Write mpi, 127*8-1 bits',
|
||||
'ASN.1 Write mpi, 255*8 bits',
|
||||
'ASN.1 Write mpi, 255*8-1 bits',
|
||||
'ASN.1 Write mpi, 256*8-1 bits',
|
||||
],
|
||||
'test_suite_debug': [
|
||||
# Following tests depends on BIGNUM_C
|
||||
'Debug print mbedtls_mpi #2: 3 bits',
|
||||
'Debug print mbedtls_mpi: 0 (empty representation)',
|
||||
'Debug print mbedtls_mpi: 0 (non-empty representation)',
|
||||
'Debug print mbedtls_mpi: 49 bits',
|
||||
'Debug print mbedtls_mpi: 759 bits',
|
||||
'Debug print mbedtls_mpi: 764 bits #1',
|
||||
'Debug print mbedtls_mpi: 764 bits #2',
|
||||
],
|
||||
}
|
||||
}
|
||||
},
|
||||
'analyze_driver_vs_reference_ffdh_alg': {
|
||||
'test_function': do_analyze_driver_vs_reference,
|
||||
'args': {
|
||||
|
@@ -111,7 +111,7 @@ def hack_dependencies_not_implemented(dependencies: List[str]) -> None:
|
||||
_implemented_dependencies = \
|
||||
read_implemented_dependencies('include/psa/crypto_config.h')
|
||||
if not all((dep.lstrip('!') in _implemented_dependencies or
|
||||
'PSA_WANT' not in dep)
|
||||
not dep.lstrip('!').startswith('PSA_WANT'))
|
||||
for dep in dependencies):
|
||||
dependencies.append('DEPENDENCY_NOT_IMPLEMENTED_YET')
|
||||
|
||||
@@ -121,19 +121,15 @@ def tweak_key_pair_dependency(dep: str, usage: str):
|
||||
symbols according to the required usage.
|
||||
"""
|
||||
ret_list = list()
|
||||
# Note: this LEGACY replacement for RSA is temporary and it's going to be
|
||||
# aligned with ECC one in #7772.
|
||||
if dep.endswith('RSA_KEY_PAIR'):
|
||||
ret_list.append(re.sub(r'RSA_KEY_PAIR\Z', r'RSA_KEY_PAIR_LEGACY', dep))
|
||||
elif dep.endswith('ECC_KEY_PAIR'):
|
||||
if dep.endswith('KEY_PAIR'):
|
||||
if usage == "BASIC":
|
||||
# BASIC automatically includes IMPORT and EXPORT for test purposes (see
|
||||
# config_psa.h).
|
||||
ret_list.append(re.sub(r'ECC_KEY_PAIR', r'ECC_KEY_PAIR_BASIC', dep))
|
||||
ret_list.append(re.sub(r'ECC_KEY_PAIR', r'ECC_KEY_PAIR_IMPORT', dep))
|
||||
ret_list.append(re.sub(r'ECC_KEY_PAIR', r'ECC_KEY_PAIR_EXPORT', dep))
|
||||
ret_list.append(re.sub(r'KEY_PAIR', r'KEY_PAIR_BASIC', dep))
|
||||
ret_list.append(re.sub(r'KEY_PAIR', r'KEY_PAIR_IMPORT', dep))
|
||||
ret_list.append(re.sub(r'KEY_PAIR', r'KEY_PAIR_EXPORT', dep))
|
||||
elif usage == "GENERATE":
|
||||
ret_list.append(re.sub(r'ECC_KEY_PAIR', r'ECC_KEY_PAIR_GENERATE', dep))
|
||||
ret_list.append(re.sub(r'KEY_PAIR', r'KEY_PAIR_GENERATE', dep))
|
||||
else:
|
||||
# No replacement to do in this case
|
||||
ret_list.append(dep)
|
||||
@@ -156,10 +152,8 @@ class Information:
|
||||
def remove_unwanted_macros(
|
||||
constructors: macro_collector.PSAMacroEnumerator
|
||||
) -> None:
|
||||
# Mbed TLS doesn't support finite-field DH yet and will not support
|
||||
# finite-field DSA. Don't attempt to generate any related test case.
|
||||
constructors.key_types.discard('PSA_KEY_TYPE_DH_KEY_PAIR')
|
||||
constructors.key_types.discard('PSA_KEY_TYPE_DH_PUBLIC_KEY')
|
||||
# Mbed TLS does not support finite-field DSA.
|
||||
# Don't attempt to generate any related test case.
|
||||
constructors.key_types.discard('PSA_KEY_TYPE_DSA_KEY_PAIR')
|
||||
constructors.key_types.discard('PSA_KEY_TYPE_DSA_PUBLIC_KEY')
|
||||
|
||||
@@ -265,12 +259,16 @@ class KeyTypeNotSupported:
|
||||
|
||||
ECC_KEY_TYPES = ('PSA_KEY_TYPE_ECC_KEY_PAIR',
|
||||
'PSA_KEY_TYPE_ECC_PUBLIC_KEY')
|
||||
DH_KEY_TYPES = ('PSA_KEY_TYPE_DH_KEY_PAIR',
|
||||
'PSA_KEY_TYPE_DH_PUBLIC_KEY')
|
||||
|
||||
def test_cases_for_not_supported(self) -> Iterator[test_case.TestCase]:
|
||||
"""Generate test cases that exercise the creation of keys of unsupported types."""
|
||||
for key_type in sorted(self.constructors.key_types):
|
||||
if key_type in self.ECC_KEY_TYPES:
|
||||
continue
|
||||
if key_type in self.DH_KEY_TYPES:
|
||||
continue
|
||||
kt = crypto_knowledge.KeyType(key_type)
|
||||
yield from self.test_cases_for_key_type_not_supported(kt)
|
||||
for curve_family in sorted(self.constructors.ecc_curves):
|
||||
@@ -280,6 +278,13 @@ class KeyTypeNotSupported:
|
||||
kt, param_descr='type')
|
||||
yield from self.test_cases_for_key_type_not_supported(
|
||||
kt, 0, param_descr='curve')
|
||||
for dh_family in sorted(self.constructors.dh_groups):
|
||||
for constr in self.DH_KEY_TYPES:
|
||||
kt = crypto_knowledge.KeyType(constr, [dh_family])
|
||||
yield from self.test_cases_for_key_type_not_supported(
|
||||
kt, param_descr='type')
|
||||
yield from self.test_cases_for_key_type_not_supported(
|
||||
kt, 0, param_descr='group')
|
||||
|
||||
def test_case_for_key_generation(
|
||||
key_type: str, bits: int,
|
||||
@@ -308,6 +313,8 @@ class KeyGenerate:
|
||||
|
||||
ECC_KEY_TYPES = ('PSA_KEY_TYPE_ECC_KEY_PAIR',
|
||||
'PSA_KEY_TYPE_ECC_PUBLIC_KEY')
|
||||
DH_KEY_TYPES = ('PSA_KEY_TYPE_DH_KEY_PAIR',
|
||||
'PSA_KEY_TYPE_DH_PUBLIC_KEY')
|
||||
|
||||
@staticmethod
|
||||
def test_cases_for_key_type_key_generation(
|
||||
@@ -333,9 +340,14 @@ class KeyGenerate:
|
||||
else:
|
||||
generate_dependencies = fix_key_pair_dependencies(import_dependencies, 'GENERATE')
|
||||
for bits in kt.sizes_to_test():
|
||||
if kt.name == 'PSA_KEY_TYPE_RSA_KEY_PAIR':
|
||||
size_dependency = "PSA_VENDOR_RSA_GENERATE_MIN_KEY_BITS <= " + str(bits)
|
||||
test_dependencies = generate_dependencies + [size_dependency]
|
||||
else:
|
||||
test_dependencies = generate_dependencies
|
||||
yield test_case_for_key_generation(
|
||||
kt.expression, bits,
|
||||
finish_family_dependencies(generate_dependencies, bits),
|
||||
finish_family_dependencies(test_dependencies, bits),
|
||||
str(bits),
|
||||
result
|
||||
)
|
||||
@@ -345,12 +357,18 @@ class KeyGenerate:
|
||||
for key_type in sorted(self.constructors.key_types):
|
||||
if key_type in self.ECC_KEY_TYPES:
|
||||
continue
|
||||
if key_type in self.DH_KEY_TYPES:
|
||||
continue
|
||||
kt = crypto_knowledge.KeyType(key_type)
|
||||
yield from self.test_cases_for_key_type_key_generation(kt)
|
||||
for curve_family in sorted(self.constructors.ecc_curves):
|
||||
for constr in self.ECC_KEY_TYPES:
|
||||
kt = crypto_knowledge.KeyType(constr, [curve_family])
|
||||
yield from self.test_cases_for_key_type_key_generation(kt)
|
||||
for dh_family in sorted(self.constructors.dh_groups):
|
||||
for constr in self.DH_KEY_TYPES:
|
||||
kt = crypto_knowledge.KeyType(constr, [dh_family])
|
||||
yield from self.test_cases_for_key_type_key_generation(kt)
|
||||
|
||||
class OpFail:
|
||||
"""Generate test cases for operations that must fail."""
|
||||
|
@@ -667,6 +667,11 @@ def parse_function_code(funcs_f, dependencies, suite_dependencies):
|
||||
code = code.replace(name, 'test_' + name, 1)
|
||||
name = 'test_' + name
|
||||
|
||||
# If a test function has no arguments then add 'void' argument to
|
||||
# avoid "-Wstrict-prototypes" warnings from clang
|
||||
if len(args) == 0:
|
||||
code = code.replace('()', '(void)', 1)
|
||||
|
||||
for line in funcs_f:
|
||||
if re.search(END_CASE_REGEX, line):
|
||||
break
|
||||
|
@@ -647,7 +647,7 @@ void func()
|
||||
self.assertEqual(arg, [])
|
||||
expected = '''#line 1 "test_suite_ut.function"
|
||||
|
||||
void test_func()
|
||||
void test_func(void)
|
||||
{
|
||||
ba ba black sheep
|
||||
have you any wool
|
||||
@@ -690,7 +690,7 @@ exit:
|
||||
|
||||
expected = '''#line 1 "test_suite_ut.function"
|
||||
|
||||
void test_func()
|
||||
void test_func(void)
|
||||
{
|
||||
ba ba black sheep
|
||||
have you any wool
|
||||
@@ -750,7 +750,7 @@ exit:
|
||||
void
|
||||
|
||||
|
||||
test_func()
|
||||
test_func(void)
|
||||
{
|
||||
ba ba black sheep
|
||||
have you any wool
|
||||
@@ -803,7 +803,7 @@ exit:
|
||||
|
||||
|
||||
|
||||
void test_func()
|
||||
void test_func(void)
|
||||
{
|
||||
ba ba black sheep
|
||||
have you any wool
|
||||
@@ -1139,7 +1139,7 @@ void func2()
|
||||
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
#line 13 "test_suite_ut.function"
|
||||
void test_func1()
|
||||
void test_func1(void)
|
||||
{
|
||||
exit:
|
||||
;
|
||||
@@ -1156,7 +1156,7 @@ void test_func1_wrapper( void ** params )
|
||||
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
#line 19 "test_suite_ut.function"
|
||||
void test_func2()
|
||||
void test_func2(void)
|
||||
{
|
||||
exit:
|
||||
;
|
||||
|
Reference in New Issue
Block a user