Skip to content

Commit

Permalink
spake2: bump curve25519-dalek to v3.0; rand_core => v0.5
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
tarcieri committed Jan 22, 2022
1 parent 22259ab commit 530d28d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 60 deletions.
87 changes: 43 additions & 44 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 4 additions & 10 deletions spake2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,18 @@ authors = ["Brian Warner <[email protected]>"]
description = "The SPAKE2 password-authenticated key-exchange algorithm."
documentation = "https://docs.rs/spake2"
homepage = "https://github.com/RustCrypto/PAKEs"
repository = "https://github.com/RustCrypto/PAKEs"
repository = "https://github.com/RustCrypto/PAKEs/tree/master/spake2"
license = "MIT OR Apache-2.0"
keywords = ["crypto", "pake", "authentication"]
categories = ["cryptography", "authentication"]
exclude = [".gitignore"]
readme = "README.md"
edition = "2018"
edition = "2021"
rust-version = "1.56"

[package.metadata.release]
tag-prefix = "spake2-v"
tag-message = "(cargo-release) spake2-v{{version}}"
pre-release-commit-message = "(cargo-release) spake2-v{{version}}"
pro-release-commit-message = "(cargo-release) start next development iteration spake2-v{{version}}"

[dependencies]
curve25519-dalek = "1.2"
rand = "0.6"
curve25519-dalek = "3"
rand_core = { version = "0.5", default-features = false, features = ["getrandom"] }
sha2 = "0.9"
hkdf = "0.11"
hex = "0.4"
Expand Down
12 changes: 6 additions & 6 deletions spake2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -286,7 +286,7 @@ pub trait Group {
fn hash_to_scalar(s: &[u8]) -> Self::Scalar;
fn random_scalar<T>(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<u8>;
fn bytes_to_element(b: &[u8]) -> Option<Self::Element>;
Expand Down Expand Up @@ -352,7 +352,7 @@ impl Group for Ed25519Group {
}
fn random_scalar<T>(cspring: &mut T) -> c2_Scalar
where
T: Rng + CryptoRng,
T: RngCore + CryptoRng,
{
c2_Scalar::random(cspring)
}
Expand Down Expand Up @@ -632,19 +632,19 @@ impl<G: Group> SPAKE2<G> {
}

pub fn start_a(password: &Password, id_a: &Identity, id_b: &Identity) -> (SPAKE2<G>, Vec<u8>) {
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<G>, Vec<u8>) {
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<G>, Vec<u8>) {
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)
}
Expand Down

0 comments on commit 530d28d

Please sign in to comment.