Skip to content

Conversation

@masihyeganeh
Copy link
Contributor

I'm trying to fix #62, but I'm not sure I'm on the right track.
I read source code of other implementations of variable-length nonce GCM. They do it like this:

  • if nonce is 12 bytes, copy the nonce in counter and add 1 to the last bit
  • else copy GHASH of nonce to counter

I did that here. Maybe it's wrong. I'm not sure.
This will be a breaking change but as mentioned in here, it is time to introduce breaking changes.

fn encrypt_in_place_detached(
&self,
nonce: &GenericArray<u8, Self::NonceSize>,
nonce: &[u8],
Copy link
Member

Choose a reason for hiding this comment

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

This would require a change in the Aead trait. See RustCrypto/traits#65

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. I did that too

Copy link
Member

Choose a reason for hiding this comment

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

Aah, apologies!

@tarcieri
Copy link
Member

@masihyeganeh so there's another option which preserves type safety for all nonce sizes and avoids making changes to the underlying trait... that would be making the AES implementation generic around different nonce sizes much in the same way it's already generic around B::ParBlocks.

I think that's probably the best way to go in general, actually. If you'd like I can adapt your PR to do do that, as generic-array and typenum are a bit mindbending.

@masihyeganeh
Copy link
Contributor Author

@tarcieri That would be great. let me know if I can help with that

@tarcieri
Copy link
Member

I've open a PR based on this one which makes AesGcm generic around the nonce size: #126

@tarcieri tarcieri closed this Mar 14, 2020
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.

GCM: Allow nonces of any length

2 participants