1
0
mirror of https://github.com/ARMmbed/mbedtls.git synced 2025-05-10 00:49:04 +08:00

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 <yanray.wang@arm.com>
This commit is contained in:
Arto Kinnunen 2023-04-14 17:21:22 +08:00 committed by Yanray Wang
parent 0f06618db0
commit b1c626b5c6

View File

@ -76,6 +76,9 @@ typedef struct mbedtls_aes_context {
int MBEDTLS_PRIVATE(nr); /*!< The number of rounds. */ int MBEDTLS_PRIVATE(nr); /*!< The number of rounds. */
size_t MBEDTLS_PRIVATE(rk_offset); /*!< The offset in array elements to AES size_t MBEDTLS_PRIVATE(rk_offset); /*!< The offset in array elements to AES
round keys in the buffer. */ 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 uint32_t MBEDTLS_PRIVATE(buf)[68]; /*!< Unaligned data buffer. This buffer can
hold 32 extra Bytes, which can be used for hold 32 extra Bytes, which can be used for
one of the following purposes: one of the following purposes:
@ -84,6 +87,7 @@ typedef struct mbedtls_aes_context {
<li>Simplifying key expansion in the 256-bit <li>Simplifying key expansion in the 256-bit
case by generating an extra round key. case by generating an extra round key.
</li></ul> */ </li></ul> */
#endif /* MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH && !MBEDTLS_PADLOCK_C */
} }
mbedtls_aes_context; mbedtls_aes_context;