Skip to content
0.2.0-dev Download ZIP
72 lines ·2.8 KB Raw
1/*
2 * TF-PSA-Crypto configuration checks
3 */
4/*
5 * Copyright The Mbed TLS Contributors
6 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
7 */
8
9#include "tf_psa_crypto_platform_requirements.h"
10
11/* Detect whether this is a normal build of the library, or a build of
12 * libtestdriver1, where all identifiers starting with normal prefixes
13 * have LIBTESTDRIVER1_ prepended. Do this without relying on
14 * any headers, since this has to happen before we include
15 * tf_psa_crypto/build_info.h.
16 *
17 * In the libtestdriver1 build, the next two code lines are
18 * `#define LIBTESTDRIVER_FOO 1` and
19 * `#if LIBTESTDRIVER_FOO == LIBTESTDRIVER_FOO` so the conditional is true.
20 * In a normal build, `LIBTESTDRIVER1_TF_PSA_CRYPTO_MARKER` remains
21 * undefined so the conditional is false.
22 */
23#define TF_PSA_CRYPTO_MARKER 1
24#if LIBTESTDRIVER1_TF_PSA_CRYPTO_MARKER == TF_PSA_CRYPTO_MARKER
25#define TF_PSA_CRYPTO_WE_ARE_IN_LIBTESTDRIVER1
26#endif
27#undef TF_PSA_CRYPTO_MARKER
28
29/* Completely byass generated config checks in libtestdriver1, where
30 * they aren't useful (when building test drivers, we can bypass
31 * normal configuration mechanisms if we want).
32 * This way we don't have to make them work. Since we bypass the
33 * header inclusions, the build system doesn't even need to know how
34 * to generate files with the right names and in the right locations.
35 */
36#if !defined(TF_PSA_CRYPTO_WE_ARE_IN_LIBTESTDRIVER1)
37/* Consistency checks on the user's configuration.
38 * Check that it doesn't define macros that we assume are under full
39 * control of the library, or options from past major versions that
40 * no longer have any effect.
41 * These headers are automatically generated. See
42 * framework/scripts/mbedtls_framework/config_checks_generator.py
43 *
44 * This here is the first stage, before including the user config.
45 */
46#include "tf_psa_crypto_config_check_before.h"
47/* The second stage, after including the user config but before doing
48 * any subsequent adjustment, will be included by build_info.h. */
49#define TF_PSA_CRYPTO_INCLUDE_AFTER_RAW_CONFIG "tf_psa_crypto_config_check_user.h"
50#endif /* !defined(TF_PSA_CRYPTO_WE_ARE_IN_LIBTESTDRIVER1) */
51
52#include <tf-psa-crypto/build_info.h>
53
54/* Consistency checks in the configuration: check for incompatible options,
55 * missing options when at least one of a set needs to be enabled, etc. */
56/* Manually written checks */
57#include "tf_psa_crypto_check_config.h"
58
59#if !defined(TF_PSA_CRYPTO_WE_ARE_IN_LIBTESTDRIVER1)
60/* Automatically generated checks (final stage after config adjustment) */
61#include "tf_psa_crypto_config_check_final.h"
62#endif /* !defined(TF_PSA_CRYPTO_WE_ARE_IN_LIBTESTDRIVER1) */
63
64/* For MBEDTLS_STATIC_ASSERT */
65#include "tf_psa_crypto_common.h"
66/* For PSA_HASH_LENGTH */
67#include <psa/crypto_sizes.h>
68
69/* Additional domain-specific checks */
70#if defined(MBEDTLS_PSA_CRYPTO_C)
71#include "psa_crypto_random_impl.h"
72#endif