Adjust AES RAM usage according to config options
Do not reserve additionl 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.
In baremetal configuration reserve space for 10 128-bit keys in order
to save 112 bytes of heap.
diff --git a/include/mbedtls/aes.h b/include/mbedtls/aes.h
index 94e7282..0f430a8 100644
--- a/include/mbedtls/aes.h
+++ b/include/mbedtls/aes.h
@@ -87,6 +87,9 @@
{
int nr; /*!< The number of rounds. */
uint32_t *rk; /*!< AES round keys. */
+#if defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) && !defined(MBEDTLS_PADLOCK_C)
+ uint32_t buf[44]; /*!< Unaligned data buffer */
+#else /* MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH */
uint32_t buf[68]; /*!< Unaligned data buffer. This buffer can
hold 32 extra Bytes, which can be used for
one of the following purposes:
@@ -95,6 +98,7 @@
<li>Simplifying key expansion in the 256-bit
case by generating an extra round key.
</li></ul> */
+#endif /* MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH */
}
mbedtls_aes_context;