aes: validate keys using crc before encryption/decryption
CRC is calculated when the key is set. This commit also adds new tests
for ecb encryption and decryption, simulating a fault injection after the key is set.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
diff --git a/include/mbedtls/aes.h b/include/mbedtls/aes.h
index cb7d726..5fb020f 100644
--- a/include/mbedtls/aes.h
+++ b/include/mbedtls/aes.h
@@ -90,6 +90,9 @@
#if defined(MBEDTLS_AES_SCA_COUNTERMEASURES)
uint32_t frk[8]; /*!< Fake AES round keys. */
#endif
+#if defined(MBEDTLS_VALIDATE_AES_KEYS_INTEGRITY)
+ uint16_t crc; /*!< CRC-16 of the set key */
+#endif
#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 */