- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
void subBytes(uint8_t* block, size_t count) {
for (int i = 0; i < count; i++) {
size_t x, y;
char *temp = new char[2];
sprintf(temp, "%02x", block[i]);
temp = new char[4]{ temp[0], 0x00, temp[1], 0x00 };
x = stoi(temp, 0, 16);
y = stoi(temp + 2, 0, 16);
block[i] = sBox[x][y];
delete[] temp;
}
}
void invSubBytes(uint8_t* block, size_t count) {
for (int i = 0; i < count; i += 1) {
size_t x, y;
char *temp = new char[4];
sprintf(temp, "%02x", block[i]);
temp = new char[4]{ temp[0], 0x00, temp[1], 0x00 };
x = stoi(temp, 0, 16);
y = stoi(temp + 2, 0, 16);
block[i] = invSbox[x][y];
delete[] temp;
}
}