Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:48:32

0001 /**
0002  * \file psa/crypto_adjust_config_derived.h
0003  * \brief Adjust PSA configuration by defining internal symbols
0004  *
0005  * This is an internal header. Do not include it directly.
0006  */
0007 /*
0008  *  Copyright The Mbed TLS Contributors
0009  *  SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
0010  */
0011 
0012 #ifndef PSA_CRYPTO_ADJUST_CONFIG_DERIVED_H
0013 #define PSA_CRYPTO_ADJUST_CONFIG_DERIVED_H
0014 
0015 #if !defined(TF_PSA_CRYPTO_CONFIG_FILES_READ)
0016 #error "Do not include psa/crypto_adjust_*.h manually! This can lead to problems, " \
0017     "up to and including runtime errors such as buffer overflows. " \
0018     "If you're trying to fix a complaint from check_config.h, just remove " \
0019     "it from your configuration file: since Mbed TLS 3.0, it is included " \
0020     "automatically at the right point."
0021 #endif /* */
0022 
0023 /* The number of "true" entropy sources (excluding NV seed).
0024  * This must be consistent with mbedtls_entropy_init() in entropy.c.
0025  */
0026 /* Define auxiliary macros, because in standard C, defined(xxx) is only
0027  * allowed directly on an #if or #elif line, not in recursive expansion. */
0028 #if defined(MBEDTLS_PSA_BUILTIN_GET_ENTROPY)
0029 #define MBEDTLS_PSA_BUILTIN_GET_ENTROPY_DEFINED 1
0030 #else
0031 #define MBEDTLS_PSA_BUILTIN_GET_ENTROPY_DEFINED 0
0032 #endif
0033 #if defined(MBEDTLS_PSA_DRIVER_GET_ENTROPY)
0034 #define MBEDTLS_PSA_DRIVER_GET_ENTROPY_DEFINED 1
0035 #else
0036 #define MBEDTLS_PSA_DRIVER_GET_ENTROPY_DEFINED 0
0037 #endif
0038 
0039 #define MBEDTLS_ENTROPY_TRUE_SOURCES ( \
0040         MBEDTLS_PSA_BUILTIN_GET_ENTROPY_DEFINED + \
0041         MBEDTLS_PSA_DRIVER_GET_ENTROPY_DEFINED + \
0042         0)
0043 
0044 /* Whether there is at least one entropy source for the entropy module.
0045  *
0046  * Note that when MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG is enabled, the entropy
0047  * module is unused and the configuration will typically not include any
0048  * entropy source, so this macro will typically remain undefined.
0049  */
0050 #if defined(MBEDTLS_ENTROPY_NV_SEED)
0051 #define MBEDTLS_ENTROPY_HAVE_SOURCES (MBEDTLS_ENTROPY_TRUE_SOURCES + 1)
0052 #elif MBEDTLS_ENTROPY_TRUE_SOURCES != 0
0053 #define MBEDTLS_ENTROPY_HAVE_SOURCES MBEDTLS_ENTROPY_TRUE_SOURCES
0054 #else
0055 #undef MBEDTLS_ENTROPY_HAVE_SOURCES
0056 #endif
0057 
0058 #if defined(PSA_WANT_ALG_ECDSA) || defined(PSA_WANT_ALG_DETERMINISTIC_ECDSA)
0059 #define PSA_HAVE_ALG_SOME_ECDSA
0060 #endif
0061 
0062 #if defined(PSA_HAVE_ALG_SOME_ECDSA) && defined(PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC)
0063 #define PSA_HAVE_ALG_ECDSA_SIGN
0064 #endif
0065 
0066 #if defined(PSA_HAVE_ALG_SOME_ECDSA) && defined(PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY)
0067 #define PSA_HAVE_ALG_ECDSA_VERIFY
0068 #endif
0069 
0070 #if defined(PSA_WANT_ALG_JPAKE)
0071 #define PSA_WANT_ALG_SOME_PAKE 1
0072 #endif
0073 
0074 /*
0075  * If the RNG strength is not explicitly defined in the configuration, define
0076  * it here to its default value. This ensures it is available for use in
0077  * adjusting the configuration of RNG internal modules in
0078  * config_adjust_legacy_crypto.h.
0079  */
0080 #if !defined(MBEDTLS_PSA_CRYPTO_RNG_STRENGTH)
0081 #define MBEDTLS_PSA_CRYPTO_RNG_STRENGTH 256
0082 #endif
0083 
0084 #if !defined(MBEDTLS_PSA_CRYPTO_RNG_HASH)
0085 
0086 #if defined(PSA_WANT_ALG_SHA_256)
0087 #define MBEDTLS_PSA_CRYPTO_RNG_HASH PSA_ALG_SHA_256
0088 #elif defined(PSA_WANT_ALG_SHA_512)
0089 #define MBEDTLS_PSA_CRYPTO_RNG_HASH PSA_ALG_SHA_512
0090 #else
0091 #if (defined(MBEDTLS_PSA_CRYPTO_C) && !defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG))
0092 #error "Not able to define MBEDTLS_PSA_CRYPTO_RNG_HASH for the entropy module."
0093 #endif
0094 #if defined(MBEDTLS_HMAC_DRBG_C)
0095 #error "Not able to define MBEDTLS_PSA_CRYPTO_RNG_HASH for HMAC_DRBG."
0096 #endif
0097 #endif /* !PSA_WANT_ALG_SHA_256, !PSA_WANT_ALG_SHA_512 */
0098 
0099 #endif /* !MBEDTLS_PSA_CRYPTO_RNG_HASH */
0100 
0101 #endif /* PSA_CRYPTO_ADJUST_CONFIG_DERIVED_H */