From 1c9f01889195d6d9750f9da5721ab138c2e61e59 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Wed, 27 Oct 2021 12:41:46 +0800 Subject: [PATCH] aes: fix potential unaligned access in aes-gcm --- components/mbedtls/port/aes/esp_aes_gcm.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/components/mbedtls/port/aes/esp_aes_gcm.c b/components/mbedtls/port/aes/esp_aes_gcm.c index b8cb59f229..dcbfac4ce9 100644 --- a/components/mbedtls/port/aes/esp_aes_gcm.c +++ b/components/mbedtls/port/aes/esp_aes_gcm.c @@ -108,12 +108,9 @@ static void increment32_j0(esp_gcm_context *ctx, uint8_t *j) /* Function to xor two data blocks */ static void xor_data(uint8_t *d, const uint8_t *s) { - uint32_t *dst = (uint32_t *) d; - uint32_t *src = (uint32_t *) s; - *dst++ ^= *src++; - *dst++ ^= *src++; - *dst++ ^= *src++; - *dst++ ^= *src++; + for (int i = 0; i < AES_BLOCK_BYTES; i++) { + d[i] ^= s[i]; + } }