Implement shiftRows

This commit is contained in:
Manuel Thalmann 2023-11-07 19:25:49 +01:00
parent 755623b0dc
commit 87f3102a45

View file

@ -85,7 +85,18 @@ void subBytes(t_state s) {
void shiftRows(t_state s) {
/* ??? */
for (uint8_t i = 0; i < 4; i++) {
uint32_t mask = 0xFF << (i * 8);
for (uint8_t shiftCount = 0; shiftCount < i; shiftCount++) {
for (uint8_t currentByte = 0; currentByte < 3; currentByte++) {
// Swap s[currentByte] and s[currentByte + 1]
s[currentByte] = s[currentByte] ^ (mask & s[currentByte + 1]);
s[currentByte + 1] = s[currentByte + 1] ^ (mask & s[currentByte]);
s[currentByte] = s[currentByte] ^ (mask & s[currentByte + 1]);
}
}
}
}
uint8_t xtime(uint8_t a) {