From c3f2767c2543961be7212bbd2a99cd371e1f4401 Mon Sep 17 00:00:00 2001 From: Przemek Stekiel Date: Tue, 6 Sep 2022 13:06:28 +0200 Subject: [PATCH] hash_info.h: add MBEDTLS_MAX_HASH_SIZE macro Signed-off-by: Przemek Stekiel --- library/hash_info.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/library/hash_info.h b/library/hash_info.h index 54f5f7c2f..1b7b46cda 100644 --- a/library/hash_info.h +++ b/library/hash_info.h @@ -35,6 +35,20 @@ #include "mbedtls/md.h" #include "psa/crypto.h" +/** \def MBEDTLS_HASH_MAX_SIZE + * + * Maximum size of a hash based on configuration. + */ +#if defined(MBEDTLS_MD_C) && ( \ + !defined(MBEDTLS_PSA_CRYPTO_C) || \ + MBEDTLS_MD_MAX_SIZE >= PSA_HASH_MAX_SIZE ) +#define MBEDTLS_HASH_MAX_SIZE MBEDTLS_MD_MAX_SIZE +#elif defined(MBEDTLS_PSA_CRYPTO_C) && ( \ + !defined(MBEDTLS_MD_C) || \ + PSA_HASH_MAX_SIZE >= MBEDTLS_MD_MAX_SIZE ) +#define MBEDTLS_HASH_MAX_SIZE PSA_HASH_MAX_SIZE +#endif + /** Get the output length of the given hash type from its MD type. * * \note To get the output length from the PSA alg, use \c PSA_HASH_LENGTH().