Implement shiftRows
This commit is contained in:
parent
755623b0dc
commit
87f3102a45
1 changed files with 12 additions and 1 deletions
13
aes/aes.cpp
13
aes/aes.cpp
|
@ -85,7 +85,18 @@ void subBytes(t_state s) {
|
||||||
|
|
||||||
|
|
||||||
void shiftRows(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) {
|
uint8_t xtime(uint8_t a) {
|
||||||
|
|
Loading…
Reference in a new issue