From 2be8b672cb389f1eab24644204f5570239fcb87b Mon Sep 17 00:00:00 2001
From: Manuel Thalmann <m@nuth.ch>
Date: Tue, 14 Nov 2023 08:58:09 +0100
Subject: [PATCH] Simplify key expansion

---
 aes/aes.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/aes/aes.cpp b/aes/aes.cpp
index ff69abf..9899e55 100644
--- a/aes/aes.cpp
+++ b/aes/aes.cpp
@@ -142,9 +142,7 @@ void mixColumns(t_state s) {
 // Taken from: https://www.brainkart.com/article/AES-Key-Expansion_8410/
 void expandKey(uint8_t k[16], uint32_t ek[44]) {
     for (uint8_t i = 0; i < 4; i++) {
-        for (uint8_t j = 0; j < 4; j++) {
-            *(((uint8_t*)(&(ek[i]))) + j) = k[i * 4 + j];
-        }
+        ek[i] = word(k[i], k[i + 1], k[i + 2], k[i + 3]);
     }
 
     for (uint8_t i = 4; i < 44; i++) {