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