mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-04 20:24:10 +00:00
Merge branch 'rand_core' of git://github.com/newpavlov/curve25519-dalek into newpavlov-rand_core
This commit is contained in:
commit
cf7a1a4a0f
6 changed files with 23 additions and 19 deletions
|
|
@ -26,9 +26,11 @@ features = ["nightly"]
|
|||
travis-ci = { repository = "dalek-cryptography/curve25519-dalek", branch = "master"}
|
||||
|
||||
[dev-dependencies]
|
||||
rand_os = "0.1.0"
|
||||
sha2 = { version = "0.8", default-features = false }
|
||||
bincode = "1"
|
||||
criterion = "0.2"
|
||||
rand = "0.6"
|
||||
|
||||
[[bench]]
|
||||
name = "dalek_benchmarks"
|
||||
|
|
@ -41,7 +43,7 @@ harness = false
|
|||
# match exactly, since the build.rs uses the crate itself as a library.
|
||||
|
||||
[dependencies]
|
||||
rand = { version = "0.6.0", default-features = false }
|
||||
rand_core = { version = "0.3.0", default-features = false }
|
||||
byteorder = { version = "^1.2.3", default-features = false, features = ["i128"] }
|
||||
digest = { version = "0.8", default-features = false }
|
||||
clear_on_drop = "=0.2.3"
|
||||
|
|
@ -50,7 +52,7 @@ serde = { version = "1.0", optional = true }
|
|||
packed_simd = { version = "0.3.0", features = ["into_bits"], optional = true }
|
||||
|
||||
[build-dependencies]
|
||||
rand = { version = "0.6.0", default-features = false }
|
||||
rand_core = { version = "0.3.0", default-features = false }
|
||||
byteorder = { version = "^1.2.3", default-features = false, features = ["i128"] }
|
||||
digest = { version = "0.8", default-features = false }
|
||||
clear_on_drop = "=0.2.3"
|
||||
|
|
@ -61,7 +63,7 @@ packed_simd = { version = "0.3.0", features = ["into_bits"], optional = true }
|
|||
[features]
|
||||
nightly = ["subtle/nightly", "clear_on_drop/nightly"]
|
||||
default = ["std", "u64_backend"]
|
||||
std = ["alloc", "subtle/std", "rand/std"]
|
||||
std = ["alloc", "subtle/std", "rand_core/std"]
|
||||
alloc = []
|
||||
yolocrypto = []
|
||||
|
||||
|
|
|
|||
2
build.rs
2
build.rs
|
|
@ -18,7 +18,7 @@ extern crate byteorder;
|
|||
extern crate clear_on_drop;
|
||||
extern crate core;
|
||||
extern crate digest;
|
||||
extern crate rand;
|
||||
extern crate rand_core;
|
||||
extern crate subtle;
|
||||
|
||||
#[cfg(all(feature = "nightly", feature = "packed_simd"))]
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@ extern crate packed_simd;
|
|||
extern crate byteorder;
|
||||
extern crate clear_on_drop;
|
||||
pub extern crate digest;
|
||||
extern crate rand;
|
||||
extern crate rand_core;
|
||||
#[cfg(all(test, feature = "stage2_build"))]
|
||||
extern crate rand_os;
|
||||
|
||||
// Used for traits related to constant-time code.
|
||||
extern crate subtle;
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ mod test {
|
|||
use super::*;
|
||||
|
||||
#[cfg(feature = "rand")]
|
||||
use rand::rngs::OsRng;
|
||||
use rand_os::OsRng;
|
||||
|
||||
/// Test Montgomery -> Edwards on the X/Ed25519 basepoint
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ use core::ops::{Add, Neg, Sub};
|
|||
use core::ops::{AddAssign, SubAssign};
|
||||
use core::ops::{Mul, MulAssign};
|
||||
|
||||
use rand::{CryptoRng, Rng};
|
||||
use rand_core::{CryptoRng, RngCore};
|
||||
|
||||
use digest::generic_array::typenum::U64;
|
||||
use digest::Digest;
|
||||
|
|
@ -477,8 +477,8 @@ impl RistrettoPoint {
|
|||
/// ```
|
||||
/// # extern crate curve25519_dalek;
|
||||
/// # use curve25519_dalek::ristretto::RistrettoPoint;
|
||||
/// extern crate rand;
|
||||
/// use rand::rngs::OsRng;
|
||||
/// extern crate rand_os;
|
||||
/// use rand_os::OsRng;
|
||||
///
|
||||
/// # // Need fn main() here in comment so the doctest compiles
|
||||
/// # // See https://doc.rust-lang.org/book/documentation.html#documentation-as-tests
|
||||
|
|
@ -626,7 +626,7 @@ impl RistrettoPoint {
|
|||
///
|
||||
/// # Inputs
|
||||
///
|
||||
/// * `rng`: any RNG which implements the `rand::Rng` interface.
|
||||
/// * `rng`: any RNG which implements the `RngCore + CryptoRng` interface.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
|
|
@ -638,9 +638,9 @@ impl RistrettoPoint {
|
|||
/// discrete log of the output point with respect to any other
|
||||
/// point should be unknown. The map is applied twice and the
|
||||
/// results are added, to ensure a uniform distribution.
|
||||
pub fn random<T: Rng + CryptoRng>(rng: &mut T) -> Self {
|
||||
pub fn random<T: RngCore + CryptoRng>(rng: &mut T) -> Self {
|
||||
let mut uniform_bytes = [0u8; 64];
|
||||
rng.fill(&mut uniform_bytes);
|
||||
rng.fill_bytes(&mut uniform_bytes);
|
||||
|
||||
RistrettoPoint::from_uniform_bytes(&uniform_bytes)
|
||||
}
|
||||
|
|
@ -1076,7 +1076,7 @@ impl Debug for RistrettoPoint {
|
|||
#[cfg(all(test, feature = "stage2_build"))]
|
||||
mod test {
|
||||
#[cfg(feature = "rand")]
|
||||
use rand::rngs::OsRng;
|
||||
use rand_os::OsRng;
|
||||
|
||||
use scalar::Scalar;
|
||||
use constants;
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ use core::ops::{Sub, SubAssign};
|
|||
#[allow(unused_imports)]
|
||||
use prelude::*;
|
||||
|
||||
use rand::{CryptoRng, Rng};
|
||||
use rand_core::{CryptoRng, RngCore};
|
||||
|
||||
use digest::generic_array::typenum::U64;
|
||||
use digest::Digest;
|
||||
|
|
@ -507,7 +507,7 @@ impl Scalar {
|
|||
///
|
||||
/// # Inputs
|
||||
///
|
||||
/// * `rng`: any RNG which implements the `rand::CryptoRng` interface.
|
||||
/// * `rng`: any RNG which implements the `RngCore + CryptoRng` interface.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
|
|
@ -516,20 +516,20 @@ impl Scalar {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// extern crate rand;
|
||||
/// extern crate rand_os;
|
||||
/// # extern crate curve25519_dalek;
|
||||
/// #
|
||||
/// # fn main() {
|
||||
/// use curve25519_dalek::scalar::Scalar;
|
||||
///
|
||||
/// use rand::OsRng;
|
||||
/// use rand_os::OsRng;
|
||||
///
|
||||
/// let mut csprng: OsRng = OsRng::new().unwrap();
|
||||
/// let a: Scalar = Scalar::random(&mut csprng);
|
||||
/// # }
|
||||
pub fn random<T: Rng + CryptoRng>(rng: &mut T) -> Self {
|
||||
pub fn random<T: RngCore + CryptoRng>(rng: &mut T) -> Self {
|
||||
let mut scalar_bytes = [0u8; 64];
|
||||
rng.fill(&mut scalar_bytes);
|
||||
rng.fill_bytes(&mut scalar_bytes);
|
||||
Scalar::from_bytes_mod_order_wide(&scalar_bytes)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue