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 constant time EQ for structs #101

Merged
merged 2 commits into from
Jan 29, 2020
Merged

Add constant time EQ for structs #101

merged 2 commits into from
Jan 29, 2020

Conversation

BobWall23
Copy link
Member

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.

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;
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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.

@BobWall23 BobWall23 merged commit 44894ee into master Jan 29, 2020
@BobWall23 BobWall23 deleted the 100-ct-eq branch February 4, 2020 05:23
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.

2 participants