Swap out CRC calculation in AES in favour of a simple hash

XOR the key bytes upon setting and re-check hash during each use.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
This commit is contained in:
Andrzej Kurek 2020-08-10 15:58:13 -04:00
parent a00c3eeaca
commit 9539f831b2
No known key found for this signature in database
GPG key ID: 89A90840DC388527
9 changed files with 82 additions and 79 deletions

View file

@ -91,7 +91,7 @@ typedef struct mbedtls_aes_context
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 */
uint32_t hash; /*!< hash 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 */

View file

@ -986,10 +986,6 @@
#error "MBEDTLS_HAVE_INT32/MBEDTLS_HAVE_INT64 and MBEDTLS_HAVE_ASM cannot be defined simultaneously"
#endif /* (MBEDTLS_HAVE_INT32 || MBEDTLS_HAVE_INT64) && MBEDTLS_HAVE_ASM */
#if defined(MBEDTLS_VALIDATE_AES_KEYS_INTEGRITY) && ( !defined(MBEDTLS_CRC_C) )
#error "MBEDTLS_VALIDATE_AES_KEYS_INTEGRITY defined, but not MBEDTLS_CRC_C"
#endif
/*
* Avoid warning from -pedantic. This is a convenient place for this
* workaround since this is included by every single file before the

View file

@ -2742,12 +2742,11 @@
/**
* \def MBEDTLS_VALIDATE_AES_KEYS_INTEGRITY
*
* Enable validation of AES keys by checking their CRC
* Enable validation of AES keys by checking their hash
* during every encryption/decryption.
*
* Module: library/aes.c
*
* Requires: MBEDTLS_CRC_C
*/
//#define MBEDTLS_VALIDATE_AES_KEYS_INTEGRITY