Use subtle version 0.2.0.

* CLOSES PR#66 https://github.com/isislovecruft/curve25519-dalek/pull/66
This commit is contained in:
Isis Lovecruft 2017-08-01 02:09:34 +00:00
parent 7202ab8e63
commit f2883028dc
Failed to extract signature
7 changed files with 39 additions and 36 deletions

View file

@ -33,7 +33,7 @@ version = "0.3"
version = "0.6"
[dependencies.subtle]
version = "^0.1"
version = "^0.2"
default-features = false
[dependencies.generic-array]
@ -47,7 +47,7 @@ version = "0.6"
version = "0.6"
[features]
nightly = ["radix_51"]
nightly = ["radix_51", "subtle/nightly"]
default = ["std"]
std = ["rand", "subtle/std"]
alloc = []

View file

@ -90,11 +90,12 @@ use core::ops::Index;
use constants;
use field::FieldElement;
use scalar::Scalar;
use subtle::arrays_equal;
use subtle::slices_equal;
use subtle::bytes_equal;
use subtle::CTAssignable;
use subtle::CTEq;
use subtle::CTNegatable;
use subtle::ConditionallyAssignable;
use subtle::ConditionallyNegatable;
use subtle::Equal;
// ------------------------------------------------------------------------
// Compressed points
@ -486,7 +487,7 @@ impl ValidityCheck for ExtendedPoint {
// Constant-time assignment
// ------------------------------------------------------------------------
impl CTAssignable for ProjectiveNielsPoint {
impl ConditionallyAssignable for ProjectiveNielsPoint {
fn conditional_assign(&mut self, other: &ProjectiveNielsPoint, choice: u8) {
self.Y_plus_X.conditional_assign(&other.Y_plus_X, choice);
self.Y_minus_X.conditional_assign(&other.Y_minus_X, choice);
@ -495,7 +496,7 @@ impl CTAssignable for ProjectiveNielsPoint {
}
}
impl CTAssignable for AffineNielsPoint {
impl ConditionallyAssignable for AffineNielsPoint {
fn conditional_assign(&mut self, other: &AffineNielsPoint, choice: u8) {
// PreComputedGroupElementCMove()
self.y_plus_x.conditional_assign(&other.y_plus_x, choice);
@ -504,7 +505,7 @@ impl CTAssignable for AffineNielsPoint {
}
}
impl CTAssignable for ExtendedPoint {
impl ConditionallyAssignable for ExtendedPoint {
fn conditional_assign(&mut self, other: &ExtendedPoint, choice: u8) {
self.X.conditional_assign(&other.X, choice);
self.Y.conditional_assign(&other.Y, choice);
@ -517,9 +518,9 @@ impl CTAssignable for ExtendedPoint {
// Constant-time Equality
// ------------------------------------------------------------------------
impl CTEq for ExtendedPoint {
impl Equal for ExtendedPoint {
fn ct_eq(&self, other: &ExtendedPoint) -> u8 {
arrays_equal(self.compress_edwards().as_bytes(),
slices_equal(self.compress_edwards().as_bytes(),
other.compress_edwards().as_bytes())
}
}
@ -533,7 +534,7 @@ pub trait IsIdentity {
/// Implement generic identity equality testing for a point representations
/// which have constant-time equality testing and a defined identity
/// constructor.
impl<T> IsIdentity for T where T: CTEq + Identity {
impl<T> IsIdentity for T where T: Equal + Identity {
fn is_identity(&self) -> bool {
self.ct_eq(&T::identity()) == 1u8
}
@ -1156,7 +1157,7 @@ impl ExtendedPoint {
/// x ≤ 8`, compute `x * B` in constant time, i.e., without branching
/// on x or using it as an array index.
fn select_precomputed_point<T>(x: i8, points: &[T; 8]) -> T
where T: Identity + CTAssignable, for<'a> &'a T: Neg<Output=T>
where T: Identity + ConditionallyAssignable, for<'a> &'a T: Neg<Output=T>
{
debug_assert!(x >= -8); debug_assert!(x <= 8);
@ -1371,7 +1372,7 @@ mod test {
use decaf::DecafPoint;
use field::FieldElement;
use scalar::Scalar;
use subtle::CTAssignable;
use subtle::ConditionallyAssignable;
use constants;
use super::*;

View file

@ -32,8 +32,6 @@ use generic_array::typenum::U32;
use constants;
use field::FieldElement;
use subtle::CTAssignable;
use subtle::CTNegatable;
use core::ops::{Add, Sub, Neg};
use core::ops::{AddAssign, SubAssign};
@ -46,6 +44,9 @@ use curve::EdwardsBasepointTable;
use curve::Identity;
use scalar::Scalar;
use subtle::ConditionallyAssignable;
use subtle::ConditionallyNegatable;
// ------------------------------------------------------------------------
// Compressed points
// ------------------------------------------------------------------------
@ -631,7 +632,7 @@ impl DecafBasepointTable {
// Constant-time conditional assignment
// ------------------------------------------------------------------------
impl CTAssignable for DecafPoint {
impl ConditionallyAssignable for DecafPoint {
/// Conditionally assign `other` to `self`, if `choice == 1u8`.
///
/// # Example
@ -640,7 +641,7 @@ impl CTAssignable for DecafPoint {
/// # extern crate subtle;
/// # extern crate curve25519_dalek;
/// #
/// # use subtle::CTAssignable;
/// # use subtle::ConditionallyAssignable;
/// #
/// # use curve25519_dalek::curve::Identity;
/// # use curve25519_dalek::decaf::DecafPoint;

View file

@ -22,10 +22,10 @@
use core::cmp::{Eq, PartialEq};
use subtle::arrays_equal;
use subtle::slices_equal;
use subtle::byte_is_nonzero;
use subtle::CTAssignable;
use subtle::CTEq;
use subtle::ConditionallyAssignable;
use subtle::Equal;
use constants;
@ -62,7 +62,7 @@ impl PartialEq for FieldElement {
}
}
impl CTEq for FieldElement {
impl Equal for FieldElement {
/// Test equality between two `FieldElement`s. Since the
/// internal representation is not canonical, the field elements
/// are normalized to wire format before comparison.
@ -71,7 +71,7 @@ impl CTEq for FieldElement {
///
/// `1u8` if the two `FieldElement`s are equal, and `0u8` otherwise.
fn ct_eq(&self, other: &FieldElement) -> u8 {
arrays_equal(&self.to_bytes(), &other.to_bytes())
slices_equal(&self.to_bytes(), &other.to_bytes())
}
}
@ -323,7 +323,7 @@ impl FieldElement {
#[cfg(test)]
mod test {
use field::*;
use subtle::CTNegatable;
use subtle::ConditionallyNegatable;
/// Random element a of GF(2^255-19), from Sage
/// a = 1070314506888354081329385823235218444233221\

View file

@ -30,7 +30,7 @@ use core::ops::{Sub, SubAssign};
use core::ops::{Mul, MulAssign};
use core::ops::Neg;
use subtle::CTAssignable;
use subtle::ConditionallyAssignable;
use utils::{load3, load4};
@ -189,7 +189,7 @@ impl<'a> Neg for &'a FieldElement32 {
}
}
impl CTAssignable for FieldElement32 {
impl ConditionallyAssignable for FieldElement32 {
fn conditional_assign(&mut self, f: &FieldElement32, choice: u8) {
let mask = -(choice as i32);
for i in 0..10 {

View file

@ -25,7 +25,7 @@ use core::ops::{Sub, SubAssign};
use core::ops::{Mul, MulAssign};
use core::ops::Neg;
use subtle::CTAssignable;
use subtle::ConditionallyAssignable;
use utils::load8;
@ -166,7 +166,7 @@ impl<'a> Neg for &'a FieldElement64 {
}
}
impl CTAssignable for FieldElement64 {
impl ConditionallyAssignable for FieldElement64 {
fn conditional_assign(&mut self, f: &FieldElement64, choice: u8) {
let mask = (-(choice as i64)) as u64;
for i in 0..5 {

View file

@ -45,9 +45,10 @@ use generic_array::typenum::U64;
use constants;
use utils::{load3, load4};
use subtle::CTAssignable;
use subtle::CTEq;
use subtle::arrays_equal;
use subtle::slices_equal;
use subtle::ConditionallyAssignable;
use subtle::Equal;
/// The `Scalar` struct represents an element in /l, where
///
@ -76,18 +77,18 @@ impl PartialEq for Scalar {
///
/// True if they are equal, and false otherwise.
fn eq(&self, other: &Self) -> bool {
arrays_equal(&self.0, &other.0) == 1u8
slices_equal(&self.0, &other.0) == 1u8
}
}
impl CTEq for Scalar {
impl Equal for Scalar {
/// Test equality between two `Scalar`s in constant time.
///
/// # Returns
///
/// `1u8` if they are equal, and `0u8` otherwise.
fn ct_eq(&self, other: &Self) -> u8 {
arrays_equal(&self.0, &other.0)
slices_equal(&self.0, &other.0)
}
}
@ -154,14 +155,14 @@ impl<'a> Neg for &'a Scalar {
}
}
impl CTAssignable for Scalar {
impl ConditionallyAssignable for Scalar {
/// Conditionally assign another Scalar to this one.
///
/// ```
/// # extern crate curve25519_dalek;
/// # extern crate subtle;
/// # use curve25519_dalek::scalar::Scalar;
/// # use subtle::CTAssignable;
/// # use subtle::ConditionallyAssignable;
/// # fn main() {
/// let a = Scalar([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
/// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);