-
Notifications
You must be signed in to change notification settings - Fork 25
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
feat: AES decryption #124
Conversation
51efb89
to
4225c3e
Compare
src/encryption/symmetric/aes/mod.rs
Outdated
/// 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 { |
There was a problem hiding this comment.
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
I think this will make traversing the code a bit simpler, but might make other operations like SubBytes
/AddRoundKeys
more difficult.
There was a problem hiding this comment.
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 GaloisField
implemented), and that should really be the main goal.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work sir
This commit contains 2 main changes: Updates to documentation, Using 7-degree polynomials of `BinaryField`s to represent bytes to do a multiplication instead of doing carry-less multiplication.
66a052c
to
02c20ae
Compare
src/field/binary_towers/tests.rs
Outdated
There was a problem hiding this comment.
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
There was a problem hiding this 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!
Closes #119
Some key notes/changes:
galois_multiplication
to be used formix_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 withinmix_columns()
, but since the inverseinv_mix_columns
uses 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.shift_rows
impl since I realized we could simply just userotate_left
androtate_right
found in Rust stdlib.