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

Change of Masks in MixColumns #1

Open
sayma10 opened this issue Jan 6, 2024 · 1 comment
Open

Change of Masks in MixColumns #1

sayma10 opened this issue Jan 6, 2024 · 1 comment

Comments

@sayma10
Copy link

sayma10 commented Jan 6, 2024

static void MixColumns(state_t *state)
{
uint8_t i;
uint8_t Tmp, Tm, t;
for (i = 0; i < 4; ++i)
{
t = (*state)[i][0];
Tmp = (*state)[i][0] ^ (*state)[i][1] ^ (*state)[i][2] ^ (*state)[i][3];
Tm = (*state)[i][0] ^ (*state)[i][1];
Tm = xtime(Tm);
(*state)[i][0] ^= Tm ^ Tmp;
Tm = (*state)[i][1] ^ (*state)[i][2];
Tm = xtime(Tm);
(*state)[i][1] ^= Tm ^ Tmp;
Tm = (*state)[i][2] ^ (*state)[i][3];
Tm = xtime(Tm);
(*state)[i][2] ^= Tm ^ Tmp;
Tm = (*state)[i][3] ^ t;
Tm = xtime(Tm);
(*state)[i][3] ^= Tm ^ Tmp;
}
}
Hello i wanted to ask how mix columns mask take place . I understand we need to precalculate last four mask with this function
static void calcMixColmask(uint8_t mask[10])
{
mask[6] = mul_02[mask[0]] ^ mul_03[mask[1]] ^ mask[2] ^ mask[3];
mask[7] = mask[0] ^ mul_02[mask[1]] ^ mul_03[mask[2]] ^ mask[3];
mask[8] = mask[0] ^ mask[1] ^ mul_02[mask[2]] ^ mul_03[mask[3]];
mask[9] = mul_03[mask[0]] ^ mask[1] ^ mask[2] ^ mul_02[mask[3]];
}

so in above MixColumns function with xtime ...how state masks are changed from M1 to M1', M2 to M2' etc..

@sayma10
Copy link
Author

sayma10 commented Jan 6, 2024

Also, i just noticed xtime function
static uint8_t xtime(uint8_t x)
{
return ((x << 1) ^ (((x >> 7) & 1) * 0x1b));
}
shouldnot * be & operator ?

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

1 participant