diff --git a/tests/configs/user-config-for-test.h b/tests/configs/user-config-for-test.h new file mode 100644 index 000000000..6e7c154ba --- /dev/null +++ b/tests/configs/user-config-for-test.h @@ -0,0 +1,59 @@ +/* MBEDTLS_USER_CONFIG_FILE for testing. + * Only used for a few test configurations. + * + * Typical usage (note multiple levels of quoting): + * make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'" + */ + +/* + * Copyright The Mbed TLS Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined(PSA_CRYPTO_DRIVER_TEST_ALL) + +/* Enable the use of the test driver in the library, and build the generic + * part of the test driver. */ +#define PSA_CRYPTO_DRIVER_TEST + +/* Use the accelerator driver for all cryptographic mechanisms for which + * the test driver implemented. */ +#define MBEDTLS_PSA_ACCEL_KEY_TYPE_AES +#define MBEDTLS_PSA_ACCEL_KEY_TYPE_CAMELLIA +#define MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR +#define MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR +#define MBEDTLS_PSA_ACCEL_ALG_CBC_NO_PADDING +#define MBEDTLS_PSA_ACCEL_ALG_CBC_PKCS7 +#define MBEDTLS_PSA_ACCEL_ALG_CTR +#define MBEDTLS_PSA_ACCEL_ALG_CFB +#define MBEDTLS_PSA_ACCEL_ALG_ECDSA +#define MBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA +#define MBEDTLS_PSA_ACCEL_ALG_MD2 +#define MBEDTLS_PSA_ACCEL_ALG_MD4 +#define MBEDTLS_PSA_ACCEL_ALG_MD5 +#define MBEDTLS_PSA_ACCEL_ALG_OFB +#define MBEDTLS_PSA_ACCEL_ALG_RIPEMD160 +#define MBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN +#define MBEDTLS_PSA_ACCEL_ALG_RSA_PSS +#define MBEDTLS_PSA_ACCEL_ALG_SHA_1 +#define MBEDTLS_PSA_ACCEL_ALG_SHA_224 +#define MBEDTLS_PSA_ACCEL_ALG_SHA_256 +#define MBEDTLS_PSA_ACCEL_ALG_SHA_384 +#define MBEDTLS_PSA_ACCEL_ALG_SHA_512 +#define MBEDTLS_PSA_ACCEL_ALG_XTS +#define MBEDTLS_PSA_ACCEL_ALG_CMAC +#define MBEDTLS_PSA_ACCEL_ALG_HMAC + +#endif /* PSA_CRYPTO_DRIVER_TEST_ALL */ diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 6023700d6..a20415a45 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -1511,33 +1511,8 @@ component_test_psa_crypto_config_basic() { scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_DES scripts/config.py unset MBEDTLS_DES_C - # Need to define the correct symbol and include the test driver header path in order to build with the test driver - loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_KEY_TYPE_AES" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_KEY_TYPE_CAMELLIA" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CBC_NO_PADDING" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CBC_PKCS7" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CTR" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CFB" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_ECDSA" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_MD2" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_MD4" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_MD5" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_OFB" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_RIPEMD160" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_RSA_PSS" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_1" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_224" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_256" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_384" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_512" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_XTS" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CMAC" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_HMAC" + loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST_ALL" + loc_cflags="${loc_cflags} '-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'" loc_cflags="${loc_cflags} -I../tests/include -O2" make CC=gcc CFLAGS="$loc_cflags" LDFLAGS="$ASAN_CFLAGS" @@ -2310,33 +2285,8 @@ component_test_psa_crypto_drivers () { scripts/config.py full scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS scripts/config.py set MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS - # Need to define the correct symbol and include the test driver header path in order to build with the test driver - loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_KEY_TYPE_AES" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_KEY_TYPE_CAMELLIA" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CBC_NO_PADDING" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CBC_PKCS7" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CTR" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CFB" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_ECDSA" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_MD2" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_MD4" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_MD5" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_OFB" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_RIPEMD160" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_RSA_PSS" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_1" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_224" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_256" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_384" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_SHA_512" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_XTS" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_CMAC" - loc_cflags="${loc_cflags} -DMBEDTLS_PSA_ACCEL_ALG_HMAC" + loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST_ALL" + loc_cflags="${loc_cflags} '-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'" loc_cflags="${loc_cflags} -I../tests/include -O2" make CC=gcc CFLAGS="${loc_cflags}" LDFLAGS="$ASAN_CFLAGS"