Просмотр исходного кода

aes: fix potential unaligned access in aes-gcm

Marius Vikhammer 4 лет назад
Родитель
Сommit
1cb07a1288
1 измененных файлов с 3 добавлено и 6 удалено
  1. 3 6
      components/mbedtls/port/aes/esp_aes_gcm.c

+ 3 - 6
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];
+    }
 }