From 61a6b227c7ff5d696dc1e254caebb4e5d8f3db57 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sat, 22 Jan 2022 14:40:26 -0700 Subject: spake2: bump `curve25519-dalek` to v3.0; `rand_core` => v0.5 (#85) This is a continuation of #33. It bumps `curve25519-dalek` to the latest stable release and replaces the `rand` crate with the version of `rand_core` which is compatible with `curve25519-dalek`: v0.5 (which is still a version behind) --- spake2/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'spake2/src/lib.rs') diff --git a/spake2/src/lib.rs b/spake2/src/lib.rs index 5980b95..79517a7 100644 --- a/spake2/src/lib.rs +++ b/spake2/src/lib.rs @@ -222,7 +222,7 @@ use curve25519_dalek::edwards::CompressedEdwardsY; use curve25519_dalek::edwards::EdwardsPoint as c2_Element; use curve25519_dalek::scalar::Scalar as c2_Scalar; use hkdf::Hkdf; -use rand::{rngs::OsRng, CryptoRng, Rng}; +use rand_core::{CryptoRng, OsRng, RngCore}; use sha2::{Digest, Sha256}; use std::fmt; use std::ops::Deref; @@ -286,7 +286,7 @@ pub trait Group { fn hash_to_scalar(s: &[u8]) -> Self::Scalar; fn random_scalar(cspring: &mut T) -> Self::Scalar where - T: Rng + CryptoRng; + T: RngCore + CryptoRng; fn scalar_neg(s: &Self::Scalar) -> Self::Scalar; fn element_to_bytes(e: &Self::Element) -> Vec; fn bytes_to_element(b: &[u8]) -> Option; @@ -352,7 +352,7 @@ impl Group for Ed25519Group { } fn random_scalar(cspring: &mut T) -> c2_Scalar where - T: Rng + CryptoRng, + T: RngCore + CryptoRng, { c2_Scalar::random(cspring) } @@ -632,19 +632,19 @@ impl SPAKE2 { } pub fn start_a(password: &Password, id_a: &Identity, id_b: &Identity) -> (SPAKE2, Vec) { - let mut cspring: OsRng = OsRng::new().unwrap(); + let mut cspring = OsRng; let xy_scalar: G::Scalar = G::random_scalar(&mut cspring); Self::start_a_internal(password, id_a, id_b, xy_scalar) } pub fn start_b(password: &Password, id_a: &Identity, id_b: &Identity) -> (SPAKE2, Vec) { - let mut cspring: OsRng = OsRng::new().unwrap(); + let mut cspring = OsRng; let xy_scalar: G::Scalar = G::random_scalar(&mut cspring); Self::start_b_internal(password, id_a, id_b, xy_scalar) } pub fn start_symmetric(password: &Password, id_s: &Identity) -> (SPAKE2, Vec) { - let mut cspring: OsRng = OsRng::new().unwrap(); + let mut cspring = OsRng; let xy_scalar: G::Scalar = G::random_scalar(&mut cspring); Self::start_symmetric_internal(password, id_s, xy_scalar) } -- cgit v1.2.3