From b1c626b5c68651034a68e4ed14ec98928c4388e5 Mon Sep 17 00:00:00 2001 From: Arto Kinnunen Date: Fri, 14 Apr 2023 17:21:22 +0800 Subject: [PATCH] AES: adjust AES RAM usage according to config options Do not reserve additional space for mbedtls_aes_context if config option AES_ONLY_128_BIT_KEY_LENGTH is used and PADLOCK_C is not used. This reduces RAM usage by 96 bytes. Signed-off-by: Yanray Wang --- include/mbedtls/aes.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/mbedtls/aes.h b/include/mbedtls/aes.h index 42e1fe855..a8d430614 100644 --- a/include/mbedtls/aes.h +++ b/include/mbedtls/aes.h @@ -76,6 +76,9 @@ typedef struct mbedtls_aes_context { int MBEDTLS_PRIVATE(nr); /*!< The number of rounds. */ size_t MBEDTLS_PRIVATE(rk_offset); /*!< The offset in array elements to AES round keys in the buffer. */ +#if defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) && !defined(MBEDTLS_PADLOCK_C) + uint32_t MBEDTLS_PRIVATE(buf)[44]; +#else uint32_t MBEDTLS_PRIVATE(buf)[68]; /*!< Unaligned data buffer. This buffer can hold 32 extra Bytes, which can be used for one of the following purposes: @@ -84,6 +87,7 @@ typedef struct mbedtls_aes_context {
  • Simplifying key expansion in the 256-bit case by generating an extra round key.
  • */ +#endif /* MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH && !MBEDTLS_PADLOCK_C */ } mbedtls_aes_context;