From 1f7f7172dcaa9e5e3c1f515e05f06ebafcc2a4fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 18 Jul 2022 12:04:05 +0200 Subject: [PATCH] Document existing dependency of MD_C MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Trying to compile MD_C without any of the hash modules would result in a bunch of unused parameter warning (hence errors in -Werror builds). We could silence those warnings by casting the parameters to void, but still, compiling the module in such a configuration would mean all of its functions are useless (always returning an error). Seems better to just document the dependency. Signed-off-by: Manuel Pégourié-Gonnard --- include/mbedtls/check_config.h | 11 +++++++++++ include/mbedtls/mbedtls_config.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/include/mbedtls/check_config.h b/include/mbedtls/check_config.h index 605f11a440..badd14c2a5 100644 --- a/include/mbedtls/check_config.h +++ b/include/mbedtls/check_config.h @@ -329,6 +329,17 @@ #error "!MBEDTLS_SSL_KEEP_PEER_CERTIFICATE requires MBEDTLS_SHA512_C, MBEDTLS_SHA256_C or MBEDTLS_SHA1_C" #endif +#if defined(MBEDTLS_MD_C) && !( \ + defined(MBEDTLS_MD5_C) || \ + defined(MBEDTLS_RIPEMD160_C) || \ + defined(MBEDTLS_SHA1_C) || \ + defined(MBEDTLS_SHA224_C) || \ + defined(MBEDTLS_SHA256_C) || \ + defined(MBEDTLS_SHA384_C) || \ + defined(MBEDTLS_SHA512_C) ) +#error "MBEDTLS_MD_C defined, but not all prerequisites" +#endif + #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \ ( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) ) #error "MBEDTLS_MEMORY_BUFFER_ALLOC_C defined, but not all prerequisites" diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h index 1c60ec8e49..31523dbae9 100644 --- a/include/mbedtls/mbedtls_config.h +++ b/include/mbedtls/mbedtls_config.h @@ -2423,6 +2423,9 @@ * * Enable the generic message digest layer. * + * Requires: one of: MBEDTLS_MD5_C, MBEDTLS_RIPEMD160_C, MBEDTLS_SHA1_C, + * MBEDTLS_SHA224_C, MBEDTLS_SHA256_C, MBEDTLS_SHA384_C, + * MBEDTLS_SHA512_C. * Module: library/md.c * Caller: library/constant_time.c * library/ecdsa.c