We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 19039d9 commit 7cf3c6cCopy full SHA for 7cf3c6c
src/key.rs
@@ -61,9 +61,12 @@ pub struct SecretKey([u8; constants::SECRET_KEY_SIZE]);
61
impl_display_secret!(SecretKey);
62
63
impl PartialEq for SecretKey {
64
+ /// This implementation is designed to be constant time to help prevent side channel attacks.
65
#[inline]
66
fn eq(&self, other: &Self) -> bool {
- self[..] == other[..]
67
+ let accum = self.0.iter().zip(&other.0)
68
+ .fold(0, |accum, (a, b)| accum | a ^ b);
69
+ unsafe { core::ptr::read_volatile(&accum) == 0 }
70
}
71
72
0 commit comments