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

Add AES-GCM(includes GHASH) #157

Merged
merged 13 commits into from
Sep 23, 2024
Merged

Add AES-GCM(includes GHASH) #157

merged 13 commits into from
Sep 23, 2024

Conversation

mrdaybird
Copy link
Contributor

@mrdaybird mrdaybird commented Sep 18, 2024

closes #140 (Bounty: AES-GCM)

Worklist:

  • Implement GHASH
    • Use Polynomial lib for polynomial multiplication.
  • Implement GCM
  • Add doc + comments for GCM+GHASH
  • Add tests to CTR (using NIST test vectors)
  • Add to README
  • (optional) GHASH : faster polynomial multiplication

Notes:

  1. Made some changes to already existing CTR(ctr.rs) implementation, which were required for GCM. The GCM spec requires a nonce of 96-bit and counter size of 32-bit (=> total of 128-bit), but the previous CTR implementation used a 50-50 split of block size for nonce and counter.
  2. Removed an "assert" in AES implementation which failed when encrypting a string of zeros.

@mrdaybird mrdaybird changed the title Add AES-GCM(+GHASH) Add AES-GCM(includes GHASH) Sep 18, 2024
@mrdaybird
Copy link
Contributor Author

mrdaybird commented Sep 23, 2024

@0xJepsen @brunny-eth I think this PR is ready for review!

There are a couple of more things, like updating the CTR section in README and adding a faster polynomial hash algorithm, but that can be done in another PR, this PR is already too big.

It was a fun week learning Rust and playing with bits! 😄


/// Represents the coefficients of field polynomial used in GCM
/// f = 1 + α + α^2 + α^7 + α^128
pub const GCMF_IRREDUCIBLE_POLYNOMIAL_COEFFICIENTS: [AESField; 129] = [
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if there is a better way to store this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was looking into it for a good hour, though I couldn't find anything better. :(
Maybe I should add a test to sanity check the coefficients.

@0xJepsen
Copy link
Contributor

0xJepsen commented Sep 23, 2024

If you can push up a change so that the lint passes I am happy to merge this! Like you mentioned i think a little bit of love on the readme would be good. I spent some time drawing some diagrams in ascii for GCTR here, as well as for GHASH here if you like you can grab them and put them where you think they fit if they are helpful. Also adding a link to the root readme and linking to the one you wrote would be a nice touch!

Thanks for everything! After some final touches on docs we @brunny-eth can work with you on getting you the bounty!

@0xJepsen 0xJepsen merged commit e4387fe into pluto:main Sep 23, 2024
5 checks passed
This was referenced Sep 23, 2024
@brunny-eth
Copy link
Contributor

hey @mrdaybird -- great work here, we're really happy that you chose to contribute to our project!

we're going to be awarding you with a $750 bounty for the work you've done here. Please share your preferred contact info (e-mail, telegram, etc.) here so I can reach out and coordinate payment

thanks again for your contributions! Hope you decide to stick around 😃

@mrdaybird
Copy link
Contributor Author

mrdaybird commented Sep 24, 2024

hey @mrdaybird -- great work here, we're really happy that you chose to contribute to our project! we're going to be awarding you with a $750 bounty for the work you've done here

@brunny-eth woah! awesome!

you can email me at pathakvaibhav@protonmail.com

Hope you decide to stick around 😃

Definitely! this is an amazing initiative!
I learned a lot from this project, and I am sure that I will be using this to learn about cryptography in the future.

EDIT: I have pinged you on telegram, just in case!

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.

bounty: AES-GCM
3 participants