From 5ddc30061cb740e59586098973b64898478524e8 Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Sun, 27 Jan 2019 23:13:58 -0800 Subject: [PATCH 1/2] Implement ConstantTimeEq on compressed points. --- src/edwards.rs | 10 +++++++--- src/ristretto.rs | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/edwards.rs b/src/edwards.rs index b37a9da..b750573 100644 --- a/src/edwards.rs +++ b/src/edwards.rs @@ -142,6 +142,12 @@ use traits::VartimeMultiscalarMul; #[derive(Copy, Clone, Eq, PartialEq)] pub struct CompressedEdwardsY(pub [u8; 32]); +impl ConstantTimeEq for CompressedEdwardsY { + fn ct_eq(&self, other: &CompressedEdwardsY) -> Choice { + self.as_bytes().ct_eq(other.as_bytes()) + } +} + impl Debug for CompressedEdwardsY { fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { write!(f, "CompressedEdwardsY: {:?}", self.as_bytes()) @@ -377,9 +383,7 @@ impl ConditionallySelectable for EdwardsPoint { impl ConstantTimeEq for EdwardsPoint { fn ct_eq(&self, other: &EdwardsPoint) -> Choice { - self.compress() - .as_bytes() - .ct_eq(other.compress().as_bytes()) + self.compress().ct_eq(&other.compress()) } } diff --git a/src/ristretto.rs b/src/ristretto.rs index 234af93..dd1b3a5 100644 --- a/src/ristretto.rs +++ b/src/ristretto.rs @@ -202,6 +202,12 @@ use traits::{MultiscalarMul, VartimeMultiscalarMul}; #[derive(Copy, Clone, Eq, PartialEq)] pub struct CompressedRistretto(pub [u8; 32]); +impl ConstantTimeEq for CompressedRistretto { + fn ct_eq(&self, other: &CompressedRistretto) -> Choice { + self.as_bytes().ct_eq(other.as_bytes()) + } +} + impl CompressedRistretto { /// Copy the bytes of this `CompressedRistretto`. pub fn to_bytes(&self) -> [u8; 32] { From 9cd4551b40a7328eed18717b527bc8ba9331fa27 Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Sun, 27 Jan 2019 23:17:27 -0800 Subject: [PATCH 2/2] Bump patch version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3562f0d..a437e7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "curve25519-dalek" -version = "1.0.2" +version = "1.0.3" authors = ["Isis Lovecruft ", "Henry de Valence "] readme = "README.md"