-
Notifications
You must be signed in to change notification settings - Fork 21
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 constant time EQ for structs #101
Conversation
For data types that contain private info (PrivateKey, Plaintext, DerivedSymmetricKey, and SigningKeypair), implement a constant time PartialEq, and remove the Revealed wrapper we were using around these types when comparison was needed.
src/api.rs
Outdated
impl PartialEq for DerivedSymmetricKey { | ||
fn eq(&self, other: &DerivedSymmetricKey) -> bool { | ||
let byte_pairs = self.bytes.iter().zip(other.bytes.iter()); | ||
return byte_pairs.fold(0, |acc, (next_a, next_b)| acc | (next_a ^ next_b)) == 0; |
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.
removing the ;
and the return
would be more consistent with our style.
src/api.rs
Outdated
impl PartialEq for Plaintext { | ||
fn eq(&self, other: &Plaintext) -> bool { | ||
self.bytes[..] == other.bytes[..] && self._internal_fp12 == other._internal_fp12 | ||
let byte_pairs = self.bytes.iter().zip(other.bytes.iter()); | ||
return byte_pairs.fold(0, |acc, (next_a, next_b)| acc | (next_a ^ next_b)) == 0; |
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.
removing the ;
and the return
would be more consistent with our style.
src/api.rs
Outdated
impl PartialEq for PrivateKey { | ||
fn eq(&self, other: &PrivateKey) -> bool { | ||
let byte_pairs = self.bytes.iter().zip(other.bytes.iter()); | ||
return byte_pairs.fold(0, |acc, (next_a, next_b)| acc | (next_a ^ next_b)) == 0; |
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.
removing the ;
and the return
would be more consistent with our style.
src/api_480.rs
Outdated
impl PartialEq for DerivedSymmetricKey { | ||
fn eq(&self, other: &DerivedSymmetricKey) -> bool { | ||
let byte_pairs = self.bytes.iter().zip(other.bytes.iter()); | ||
return byte_pairs.fold(0, |acc, (next_a, next_b)| acc | (next_a ^ next_b)) == 0; |
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.
removing the ;
and the return
would be more consistent with our style.
For data types that contain private info (PrivateKey, Plaintext,
DerivedSymmetricKey, and SigningKeypair), implement a constant time
PartialEq, and remove the Revealed wrapper we were using around these
types when comparison was needed.