1a8e1175bSopenharmony_ci/* MBEDTLS_USER_CONFIG_FILE for testing.
2a8e1175bSopenharmony_ci * Only used for a few test configurations.
3a8e1175bSopenharmony_ci *
4a8e1175bSopenharmony_ci * Typical usage (note multiple levels of quoting):
5a8e1175bSopenharmony_ci *     make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'"
6a8e1175bSopenharmony_ci */
7a8e1175bSopenharmony_ci
8a8e1175bSopenharmony_ci/*
9a8e1175bSopenharmony_ci *  Copyright The Mbed TLS Contributors
10a8e1175bSopenharmony_ci *  SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
11a8e1175bSopenharmony_ci */
12a8e1175bSopenharmony_ci
13a8e1175bSopenharmony_ci#if defined(PSA_CRYPTO_DRIVER_TEST_ALL)
14a8e1175bSopenharmony_ci/* PSA_CRYPTO_DRIVER_TEST_ALL activates test drivers while keeping the
15a8e1175bSopenharmony_ci * built-in implementations active. Normally setting MBEDTLS_PSA_ACCEL_xxx
16a8e1175bSopenharmony_ci * would disable MBEDTLS_PSA_BUILTIN_xxx unless fallback is activated, but
17a8e1175bSopenharmony_ci * here we arrange to have both active so that psa_crypto_*.c includes
18a8e1175bSopenharmony_ci * the built-in implementations and the driver code can call the built-in
19a8e1175bSopenharmony_ci * implementations.
20a8e1175bSopenharmony_ci *
21a8e1175bSopenharmony_ci * The point of this test mode is to verify that the
22a8e1175bSopenharmony_ci * driver entry points are called when they should be in a lightweight
23a8e1175bSopenharmony_ci * way, without requiring an actual driver. This is different from builds
24a8e1175bSopenharmony_ci * with libtestdriver1, where we make a copy of the library source code
25a8e1175bSopenharmony_ci * and use that as an external driver.
26a8e1175bSopenharmony_ci */
27a8e1175bSopenharmony_ci
28a8e1175bSopenharmony_ci/* Enable the use of the test driver in the library, and build the generic
29a8e1175bSopenharmony_ci * part of the test driver. */
30a8e1175bSopenharmony_ci#define PSA_CRYPTO_DRIVER_TEST
31a8e1175bSopenharmony_ci
32a8e1175bSopenharmony_ci/* With MBEDTLS_PSA_CRYPTO_CONFIG, if we set up the acceleration, the
33a8e1175bSopenharmony_ci * built-in implementations won't be enabled. */
34a8e1175bSopenharmony_ci#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
35a8e1175bSopenharmony_ci#error \
36a8e1175bSopenharmony_ci    "PSA_CRYPTO_DRIVER_TEST_ALL sets up a nonstandard configuration that is incompatible with MBEDTLS_PSA_CRYPTO_CONFIG"
37a8e1175bSopenharmony_ci#endif
38a8e1175bSopenharmony_ci
39a8e1175bSopenharmony_ci/* Use the accelerator driver for all cryptographic mechanisms for which
40a8e1175bSopenharmony_ci * the test driver implemented. */
41a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_KEY_TYPE_AES
42a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_KEY_TYPE_CAMELLIA
43a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY
44a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR_BASIC
45a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR_IMPORT
46a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR_EXPORT
47a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR_GENERATE
48a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR
49a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_CBC_NO_PADDING
50a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_CBC_PKCS7
51a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_CTR
52a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_CFB
53a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_ECDSA
54a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA
55a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_MD5
56a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_OFB
57a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_RIPEMD160
58a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN
59a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_RSA_PSS
60a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_SHA_1
61a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_SHA_224
62a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_SHA_256
63a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_SHA_384
64a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_SHA_512
65a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_XTS
66a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_CMAC
67a8e1175bSopenharmony_ci#define MBEDTLS_PSA_ACCEL_ALG_HMAC
68a8e1175bSopenharmony_ci
69a8e1175bSopenharmony_ci#endif  /* PSA_CRYPTO_DRIVER_TEST_ALL */
70a8e1175bSopenharmony_ci
71a8e1175bSopenharmony_ci
72a8e1175bSopenharmony_ci
73a8e1175bSopenharmony_ci#if defined(MBEDTLS_PSA_INJECT_ENTROPY)
74a8e1175bSopenharmony_ci/* The #MBEDTLS_PSA_INJECT_ENTROPY feature requires two extra platform
75a8e1175bSopenharmony_ci * functions, which must be configured as #MBEDTLS_PLATFORM_NV_SEED_READ_MACRO
76a8e1175bSopenharmony_ci * and #MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO. The job of these functions
77a8e1175bSopenharmony_ci * is to read and write from the entropy seed file, which is located
78a8e1175bSopenharmony_ci * in the PSA ITS file whose uid is #PSA_CRYPTO_ITS_RANDOM_SEED_UID.
79a8e1175bSopenharmony_ci * (These could have been provided as library functions, but for historical
80a8e1175bSopenharmony_ci * reasons, they weren't, and so each integrator has to provide a copy
81a8e1175bSopenharmony_ci * of these functions.)
82a8e1175bSopenharmony_ci *
83a8e1175bSopenharmony_ci * Provide implementations of these functions for testing. */
84a8e1175bSopenharmony_ci#include <stddef.h>
85a8e1175bSopenharmony_ciint mbedtls_test_inject_entropy_seed_read(unsigned char *buf, size_t len);
86a8e1175bSopenharmony_ciint mbedtls_test_inject_entropy_seed_write(unsigned char *buf, size_t len);
87a8e1175bSopenharmony_ci#define MBEDTLS_PLATFORM_NV_SEED_READ_MACRO mbedtls_test_inject_entropy_seed_read
88a8e1175bSopenharmony_ci#define MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO mbedtls_test_inject_entropy_seed_write
89a8e1175bSopenharmony_ci#endif /* MBEDTLS_PSA_INJECT_ENTROPY */
90