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

feat: AES decryption #124

Merged
merged 15 commits into from
Jul 8, 2024
Merged

feat: AES decryption #124

merged 15 commits into from
Jul 8, 2024

Conversation

eightfilms
Copy link
Contributor

@eightfilms eightfilms commented Jul 2, 2024

Closes #119

Some key notes/changes:

  • introduced galois_multiplication to be used for mix_columns: for encryption, we only needed to multiply column values once at worst to do a matrix multiplication for the polynomial a(x) = 3x^3 + x^2 + x + 2, so we could do it within mix_columns(), but since the inverse inv_mix_columnsuses a more complex polynomial (the inverse of a, a^-1(x) = 11x^3 + 13x^2 + 9x + 14), it would be cleaner to properly implement this fn.
  • added README details for decryption.
  • also changed shift_rows impl since I realized we could simply just use rotate_left and rotate_right found in Rust stdlib.

@eightfilms eightfilms force-pushed the bing/aes-decryption branch 3 times, most recently from 51efb89 to 4225c3e Compare July 2, 2024 07:52
@eightfilms eightfilms marked this pull request as ready for review July 2, 2024 08:03
@0xJepsen 0xJepsen requested review from 0xJepsen, Autoparallel, lonerapier and devloper and removed request for 0xJepsen July 2, 2024 13:46
/// element is treated as a polynomial.
///
/// NOTE: this multiplication is not commutative - ie. A * B may not equal B * A.
fn galois_multiplication(mut col: u8, mut multiplicant: usize) -> u8 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just want to get others' opinions, is it possible to use $GF(2^{8})$ throughout, rather than have these specific implementations?

I think this will make traversing the code a bit simpler, but might make other operations like SubBytes/AddRoundKeys more difficult.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's a good point, in some parts of the code (such as this) we are indeed operating in $GF(2^8)$. I could see this change being easier to understand/read (since we already have GaloisField implemented), and that should really be the main goal.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be a good idea. It would be nice to stand on the other primitives we have so we don't have to reinvent them every time

Copy link
Collaborator

@lonerapier lonerapier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work sir

@lonerapier lonerapier mentioned this pull request Jul 5, 2024
1 task
@eightfilms eightfilms force-pushed the bing/aes-decryption branch from 66a052c to 02c20ae Compare July 8, 2024 08:31
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This big diff is just me moving the impls into a generalized GaloisField<8, 2>, now found in gf_2_8.rs

Copy link
Contributor

@0xJepsen 0xJepsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work on this!

@0xJepsen 0xJepsen merged commit c218d47 into pluto:main Jul 8, 2024
5 checks passed
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

Successfully merging this pull request may close these issues.

feat: AES decryption
3 participants