aes-whitebox icon indicating copy to clipboard operation
aes-whitebox copied to clipboard

External encodings were not implemented?

Open tvandijck opened this issue 1 year ago • 2 comments

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.

tvandijck avatar Mar 26 '23 14:03 tvandijck

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).

balena avatar Mar 26 '23 16:03 balena

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]); } ... }

alanthie avatar Mar 29 '23 18:03 alanthie