dhuertas / AES

AES algorithm implementation in C
MIT License
615 stars 323 forks source link

Removed gcc warning #7

Closed NikitaCartes closed 4 years ago

NikitaCartes commented 4 years ago

Hi.

Removed some unused variables and includes.

Also replaced stuff like this row = (state[Nb*i+j] & 0xf0) >> 4; col = state[Nb*i+j] & 0x0f; state[Nb*i+j] = inv_s_box[16*row+col]; with state[Nb*i+j] = s_box[state[Nb*i+j]];

I can make another pull requests with this things, if you approve it (maybe add const in const parameters?):

uint8_t i; for (i = 0; i < 4; i++) { w[i] = s_box[w[i]]; } replace with for (uint8_t i = 0; i < 4; i++) { w[i] = s_box[w[i]]; }

dhuertas commented 4 years ago

Thanks for the pull request. I will gladly merge your changes.

If you agree however, I'd like you to include a small comment on one of the s_box changes explaining why that change makes complete sense. Something along these lines:

// s_box row: yyyy ----
// s_box col: ---- xxxx
// s_box[16*(yyyy) + xxxx] == s_box[yyyyxxxx]

It seems that this implementation is mostly browsed by students reading study articles about AES. It would be great if others can learn from my mistakes : )

Otherwise I can do that after merging the changes, so no big deal.

Cheers!

NikitaCartes commented 4 years ago

Thank you. Added comments.

students reading study articles about AES

Oh, it's me, heh :)