|
48 | 48 | #endif |
49 | 49 | #endif /* _MINGW32__ || (_MSC_VER && (_MSC_VER <= 1900)) */ |
50 | 50 |
|
| 51 | +/* The number of "true" entropy sources (excluding NV seed). |
| 52 | + * This must be consistent with mbedtls_entropy_init() in entropy.c. |
| 53 | + */ |
| 54 | +/* Define auxiliary macros, because in standard C, defined(xxx) is only |
| 55 | + * allowed directly on an #if or #elif line, not in recursive expansion. */ |
| 56 | +#if defined(MBEDTLS_NO_PLATFORM_ENTROPY) |
| 57 | +#define MBEDTLS_PLATFORM_ENTROPY_ENABLED 0 |
| 58 | +#else |
| 59 | +#define MBEDTLS_PLATFORM_ENTROPY_ENABLED 1 |
| 60 | +#endif |
| 61 | +#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) |
| 62 | +#define MBEDTLS_ENTROPY_HARDWARE_ALT_DEFINED 1 |
| 63 | +#else |
| 64 | +#define MBEDTLS_ENTROPY_HARDWARE_ALT_DEFINED 0 |
| 65 | +#endif |
| 66 | + |
| 67 | +#define MBEDTLS_ENTROPY_TRUE_SOURCES ( \ |
| 68 | + MBEDTLS_ENTROPY_HARDWARE_ALT_DEFINED + \ |
| 69 | + MBEDTLS_PLATFORM_ENTROPY_ENABLED + \ |
| 70 | + 0) |
| 71 | + |
| 72 | +/* Whether there is at least one entropy source for the entropy module. |
| 73 | + * |
| 74 | + * Note that when MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG is enabled, the entropy |
| 75 | + * module is unused and the configuration will typically not include any |
| 76 | + * entropy source, so this macro will typically remain undefined. |
| 77 | + */ |
| 78 | +#if defined(MBEDTLS_ENTROPY_NV_SEED) |
| 79 | +#define MBEDTLS_ENTROPY_HAVE_SOURCES (MBEDTLS_ENTROPY_TRUE_SOURCES + 1) |
| 80 | +#elif MBEDTLS_ENTROPY_TRUE_SOURCES != 0 |
| 81 | +#define MBEDTLS_ENTROPY_HAVE_SOURCES MBEDTLS_ENTROPY_TRUE_SOURCES |
| 82 | +#else |
| 83 | +#undef MBEDTLS_ENTROPY_HAVE_SOURCES |
| 84 | +#endif |
| 85 | + |
| 86 | +/* Test function dependencies can only check with defined(), |
| 87 | + * not other preprocessor expressions. */ |
| 88 | +#if MBEDTLS_ENTROPY_TRUE_SOURCES > 0 |
| 89 | +#define MBEDTLS_ENTROPY_HAVE_TRUE_SOURCES |
| 90 | +#else |
| 91 | +#undef MBEDTLS_ENTROPY_HAVE_TRUE_SOURCES |
| 92 | +#endif |
| 93 | + |
51 | 94 | /* If MBEDTLS_PSA_CRYPTO_C is defined, make sure MBEDTLS_PSA_CRYPTO_CLIENT |
52 | 95 | * is defined as well to include all PSA code. |
53 | 96 | */ |
|
0 commit comments