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

polyval: Implement GHASH #9

Merged
merged 1 commit into from
Sep 6, 2019
Merged

polyval: Implement GHASH #9

merged 1 commit into from
Sep 6, 2019

Conversation

tarcieri
Copy link
Member

@tarcieri tarcieri commented Sep 5, 2019

Implements GHASH in terms of POLYVAL as described in RFC 8452 Appendix A:

https://tools.ietf.org/html/rfc8452#appendix-A

@@ -22,6 +22,7 @@ zeroize = { version = "0.10", optional = true, default-features = false }
hex-literal = "0.1"

[features]
ghash = []
Copy link
Member Author

@tarcieri tarcieri Sep 5, 2019

Choose a reason for hiding this comment

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

Alternatively we could use the ghash crate for this. What do you think @newpavlov? I could go either way.

Copy link
Member

@newpavlov newpavlov Sep 6, 2019

Choose a reason for hiding this comment

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

Hm, I think using ghash crate would be better for visibility, but then it would be probably better to move field module to a separate crate (and you will not see polyval in a dependency tree for gmac). But if you prefer the current way I am fine with it as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

How about we leave them in the same crate for now, and I can investigate things getting VPCLMULQDQ working, and runtime CPU detection and fallback to the software implementation, and once all of that stuff is working we can investigate splitting them into separate crates?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, sounds good to me.


/// Get POLYVAL result (i.e. computed `S` field element)
fn result(self) -> Output<U16> {
let mut output: Block = self.0.result().into_bytes().as_slice().try_into().unwrap();
Copy link
Member

@newpavlov newpavlov Sep 6, 2019

Choose a reason for hiding this comment

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

I think you can replace it with a simple self.0.result().into(). GenericArray<T; U16> implements Into<[T; 16]> since generic-array v0.12.3.

Copy link
Member Author

@tarcieri tarcieri Sep 6, 2019

Choose a reason for hiding this comment

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

Thanks! I guess I knew that but did things the silly way anyway.

I was able to eliminate all use of TryInto via simple Into conversions (at least in the ghash module).

Implements GHASH in terms of POLYVAL as described in RFC 8452 Appendix A:

https://tools.ietf.org/html/rfc8452#appendix-A
@tarcieri tarcieri merged commit 8a1d1af into master Sep 6, 2019
@tarcieri tarcieri deleted the polyval/ghash branch September 6, 2019 14:33
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.

None yet

2 participants