Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External encodings were not implemented? #7

Open
tvandijck opened this issue Mar 26, 2023 · 2 comments
Open

External encodings were not implemented? #7

tvandijck opened this issue Mar 26, 2023 · 2 comments

Comments

@tvandijck
Copy link

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.

@balena
Copy link
Owner

balena commented Mar 26, 2023

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

@alanthie
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants