aes-whitebox
aes-whitebox copied to clipboard
External encodings were not implemented?
Is that the reason why all the values in XorTable are entirely the same for every entry?
Right now, you could get a ton more performance if you just didn't generate those and do:
n0 = ((aa >> 28) & 0xf) ^ ((bb >> 28) & 0xf);
etc.
which is what the current tables achieve, since the codegen does:
uint8_t Xor[Nr-1][96][16][16];
for (int r = 0; r < Nr-1; r++)
for (int n = 0; n < 96; n++)
for (int i = 0; i < 16; i++)
for (int j = 0; j < 16; j++)
Xor[r][n][i][j] = i ^ j;
r and n are no factor in the calculation, which is either a bug, or we can just get rid of this table entirely.
Good point. Indeed it is missing to implement external encoding. I left it this way to allow its implementation at a later stage (which never happened, yet).
Side note: You can have unlimited AES size by moving stuff into the heap using vector without changing the code much. I have tested AES 8196 (and exporting/importing tables into/from files) void GenerateXorTable(FILE* out, int Nr, wbaes_vbase* instance_aes, bool verbose = false) { std::vector<std::vector<std::vector<std::vector<uint8_t>>>>* pXor = new std::vector<std::vector<std::vector<std::vector<uint8_t>>>>(Nr-1); std::vector<std::vector<std::vector<std::vector<uint8_t>>>>& Xor = *pXor; for(int i=0;i<Nr-1;i++) { Xor[i].resize(96); for(int j=0;j<96;j++) { Xor[i][j].resize(16); for(int k=0;k<16;k++) Xor[i][j][k].resize(16); } }
for (int r = 0; r < Nr-1; r++) for (int n = 0; n < 96; n++) for (int i = 0; i < 16; i++) for (int j = 0; j < 16; j++) { Xor[r][n][i][j] = i ^ j; instance_aes->setXor(r, n, j, i, Xor[r][n][i][j]); } ... }