From 66580d284dd6afeaa337b4a5c28fc0ce262afd79 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Fri, 8 Sep 2017 10:06:41 +0100 Subject: [PATCH] Add internal macro ENTROPY_HAVE_STRONG indicating strong entropy This commit adds the macro ENTROPY_HAVE_STRONG to the helper test file tests/suites/helpers.function to be able to make tests depend on the presence of strong entropy. --- library/entropy.c | 3 +++ tests/suites/helpers.function | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/library/entropy.c b/library/entropy.c index 3622ad280..b45384dbe 100644 --- a/library/entropy.c +++ b/library/entropy.c @@ -60,6 +60,9 @@ void mbedtls_entropy_init( mbedtls_entropy_context *ctx ) { memset( ctx, 0, sizeof(mbedtls_entropy_context) ); + /* Reminder: Update ENTROPY_HAVE_STRONG in the test files + * when adding more strong entropy sources here. */ + #if defined(MBEDTLS_THREADING_C) mbedtls_mutex_init( &ctx->mutex ); #endif diff --git a/tests/suites/helpers.function b/tests/suites/helpers.function index 6af918cad..b80831ee5 100644 --- a/tests/suites/helpers.function +++ b/tests/suites/helpers.function @@ -55,6 +55,18 @@ typedef UINT32 uint32_t; } #endif +/* Helper flags for complex dependencies */ + +/* Indicates whether we expect mbedtls_entropy_init + * to initialize some strong entropy source. */ +#if defined(MBEDTLS_TEST_NULL_ENTROPY) || \ + ( !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) && \ + ( !defined(MBEDTLS_NO_PLATFORM_ENTROPY) || \ + defined(MBEDTLS_HAVEGE_C) || \ + defined(MBEDTLS_ENTROPY_HARDWARE_ALT) ) ) +#define ENTROPY_HAVE_STRONG +#endif + static int unhexify( unsigned char *obuf, const char *ibuf ) { unsigned char c, c2;