Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ members = [

[profile.dev]
opt-level = 2

[patch.crates-io.rand]
git = "https://github.com/rust-random/rand"
2 changes: 1 addition & 1 deletion aucpace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ rust-version = "1.85"
[dependencies]
curve25519-dalek = { version = "5.0.0-pre.3", default-features = false, features = ["digest", "rand_core"] }
password-hash = { version = "0.6.0-rc.6", default-features = false, features = ["phc", "rand_core"] }
rand_core = { version = "0.10.0-rc-2", default-features = false }
rand_core = { version = "0.10.0-rc-3", default-features = false }
subtle = { version = "2.4", default-features = false }

# optional dependencies
Expand Down
4 changes: 2 additions & 2 deletions aucpace/examples/key_agreement.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use aucpace::{
Client, ClientMessage, Database, OsRng, Result, Server, ServerMessage, rand_core::TryRngCore,
Client, ClientMessage, Database, Result, Server, ServerMessage, SysRng, rand_core::TryRngCore,
};
use curve25519_dalek::ristretto::RistrettoPoint;
use password_hash::phc::{ParamsString, SaltString};
Expand Down Expand Up @@ -40,7 +40,7 @@ fn main() -> Result<()> {
let server_socket: SocketAddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 25519);

// random number generator from OS
let mut rng = OsRng.unwrap_err();
let mut rng = SysRng.unwrap_err();

// register the user in the database
let mut base_client = Client::new(rng);
Expand Down
4 changes: 2 additions & 2 deletions aucpace/examples/key_agreement_no_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
extern crate std;

use aucpace::{
Client, ClientMessage, Database, OsRng, Result, Server, ServerMessage, rand_core::TryRngCore,
Client, ClientMessage, Database, Result, Server, ServerMessage, SysRng, rand_core::TryRngCore,
};
use curve25519_dalek::ristretto::RistrettoPoint;
use password_hash::phc::{ParamsString, SaltString};
Expand All @@ -31,7 +31,7 @@ fn main() -> Result<()> {
const PASSWORD: &[u8] = b"4d1rA_aND-Gr4Y_aRe_tH3-b3sT <3";

// get system random number generator
let mut rng = OsRng.unwrap_err();
let mut rng = SysRng.unwrap_err();

// register the user in the database
let mut base_server = Server::new(rng);
Expand Down
6 changes: 3 additions & 3 deletions aucpace/examples/key_agreement_partial_aug.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use aucpace::rand_core::TryRngCore;
use aucpace::{
Client, ClientMessage, Database, Error, OsRng, PartialAugDatabase, Result, Server,
ServerMessage,
Client, ClientMessage, Database, Error, PartialAugDatabase, Result, Server, ServerMessage,
SysRng,
};
use curve25519_dalek::{ristretto::RistrettoPoint, scalar::Scalar};
use password_hash::phc::{ParamsString, SaltString};
Expand Down Expand Up @@ -42,7 +42,7 @@ fn main() -> Result<()> {
let server_socket: SocketAddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 25519);

// random number generator from OS
let mut rng = OsRng.unwrap_err();
let mut rng = SysRng.unwrap_err();

// register the user in the database
let mut base_client = Client::new(rng);
Expand Down
4 changes: 2 additions & 2 deletions aucpace/examples/key_agreement_strong.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use aucpace::{
Client, ClientMessage, OsRng, Result, Server, ServerMessage, StrongDatabase,
Client, ClientMessage, Result, Server, ServerMessage, StrongDatabase, SysRng,
rand_core::TryRngCore,
};
use curve25519_dalek::{ristretto::RistrettoPoint, scalar::Scalar};
Expand Down Expand Up @@ -41,7 +41,7 @@ fn main() -> Result<()> {
let server_socket: SocketAddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 25519);

// random number generator from OS
let mut rng = OsRng.unwrap_err();
let mut rng = SysRng.unwrap_err();

// register the user in the database
let mut base_client = Client::new(rng);
Expand Down
6 changes: 3 additions & 3 deletions aucpace/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ mod tests {
use super::*;

#[cfg(all(feature = "rand", feature = "sha2"))]
use crate::{OsRng, rand_core::TryRngCore};
use crate::{SysRng, rand_core::TryRngCore};

#[test]
#[cfg(all(feature = "alloc", feature = "rand", feature = "scrypt"))]
Expand All @@ -1063,7 +1063,7 @@ mod tests {
let username = "worf@starship.enterprise";
let password = "data_x_worf_4ever_<3";
let mut bytes = [0u8; Salt::RECOMMENDED_LENGTH];
OsRng.try_fill_bytes(&mut bytes).unwrap();
SysRng.try_fill_bytes(&mut bytes).unwrap();
let salt = Salt::new(&bytes).expect("Salt length invariant broken.");
// These are weak parameters, do not use them
// they are used here to make the test run faster
Expand All @@ -1087,7 +1087,7 @@ mod tests {
fn test_client_doesnt_accept_insecure_ssid() {
use crate::Client;

let mut client = Client::new(OsRng.unwrap_err());
let mut client = Client::new(SysRng.unwrap_err());
let res = client.begin_prestablished_ssid("bad ssid");
assert!(matches!(res, Err(Error::InsecureSsid)));
}
Expand Down
14 changes: 7 additions & 7 deletions aucpace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,16 @@ pub use self::database::PartialAugDatabase;
pub use self::database::StrongDatabase;

#[cfg(feature = "rand")]
pub use rand::rngs::OsRng;
pub use rand::rngs::SysRng;

/// Infallible version of `OsRng` which panics on error
/// Infallible version of `SysRng` which panics on error
#[cfg(feature = "rand")]
pub type UnwrapOsRng = rand_core::UnwrapErr<OsRng>;
pub type UnwrapSysRng = rand_core::UnwrapErr<SysRng>;

/// Default Server instantiation with `SHA512`, `OsRng` and a nonce size of 16 bytes
/// Default Server instantiation with `SHA512`, `SysRng` and a nonce size of 16 bytes
#[cfg(all(feature = "sha2", feature = "rand"))]
pub type Server = AuCPaceServer<sha2::Sha512, UnwrapOsRng, 16>;
pub type Server = AuCPaceServer<sha2::Sha512, UnwrapSysRng, 16>;

/// Default Client instantiation with `SHA512`, `Scrypt`, `OsRng` and a nonce size of 16 bytes
/// Default Client instantiation with `SHA512`, `Scrypt`, `SysRng` and a nonce size of 16 bytes
#[cfg(all(feature = "scrypt", feature = "sha2", feature = "rand"))]
pub type Client = AuCPaceClient<sha2::Sha512, scrypt::Scrypt, UnwrapOsRng, 16>;
pub type Client = AuCPaceClient<sha2::Sha512, scrypt::Scrypt, UnwrapSysRng, 16>;
8 changes: 4 additions & 4 deletions aucpace/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,13 +734,13 @@ mod tests {
use curve25519_dalek::constants::RISTRETTO_BASEPOINT_POINT;

#[cfg(all(feature = "sha2", feature = "rand"))]
use crate::{OsRng, rand_core::TryRngCore};
use crate::{SysRng, rand_core::TryRngCore};

#[test]
#[cfg(all(feature = "sha2", feature = "rand"))]
fn test_server_doesnt_accept_insecure_ssid() {
use crate::Server;
let mut server = Server::new(OsRng.unwrap_err());
let mut server = Server::new(SysRng.unwrap_err());
let res = server.begin_prestablished_ssid("bad ssid");
assert!(matches!(res, Err(Error::InsecureSsid)));
}
Expand Down Expand Up @@ -849,7 +849,7 @@ mod tests {
b"bobbyyyy",
RistrettoPoint::identity(),
&FakeDatabase(),
OsRng.unwrap_err(),
SysRng.unwrap_err(),
);

if let Err(e) = res {
Expand Down Expand Up @@ -877,7 +877,7 @@ mod tests {
b"bobbyyyy",
RistrettoPoint::identity(),
&FakeDatabase(),
OsRng.unwrap_err(),
SysRng.unwrap_err(),
);

if let Err(e) = res {
Expand Down
6 changes: 3 additions & 3 deletions aucpace/tests/test_key_agreement.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg(all(feature = "alloc", feature = "rand"))]

use aucpace::{
Client, ClientMessage, Database, OsRng, Result, Server, ServerMessage,
Client, ClientMessage, Database, Result, Server, ServerMessage, SysRng,
client::{AuCPaceClientPreAug, AuCPaceClientRecvServerKey},
rand_core::TryRngCore,
server::{AuCPaceServerAugLayer, AuCPaceServerRecvClientKey},
Expand Down Expand Up @@ -234,7 +234,7 @@ fn test_key_agreement_prestablished_ssid_implicit_auth() -> Result<()> {

/// Perform the initialisation step for all tests
fn init() -> Result<(Client, Server, SingleUserDatabase)> {
let rng = OsRng.unwrap_err();
let rng = SysRng.unwrap_err();

// Create the client, server and database
let base_server = Server::new(rng);
Expand Down Expand Up @@ -268,7 +268,7 @@ fn test_core(
ClientMessage<'_, K1>,
ServerMessage<'_, K1>,
)> {
let mut rng = OsRng.unwrap_err();
let mut rng = SysRng.unwrap_err();

// ===== Augmentation Layer =====
// client initiates the augmentation phase
Expand Down
8 changes: 4 additions & 4 deletions aucpace/tests/test_key_agreement_partial_aug.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![cfg(all(feature = "alloc", feature = "partial_augmentation", feature = "rand"))]

use aucpace::{
Client, ClientMessage, Database, Error, OsRng, PartialAugDatabase, Result, Server,
ServerMessage,
Client, ClientMessage, Database, Error, PartialAugDatabase, Result, Server, ServerMessage,
SysRng,
client::{AuCPaceClientPreAug, AuCPaceClientRecvServerKey},
server::{AuCPaceServerAugLayer, AuCPaceServerRecvClientKey},
};
Expand Down Expand Up @@ -266,7 +266,7 @@ fn test_key_agreement_prestablished_ssid_implicit_auth() -> Result<()> {

/// Perform the initialisation step for all tests
fn init() -> Result<(Client, Server, SingleUserDatabase)> {
let rng = OsRng.unwrap_err();
let rng = SysRng.unwrap_err();

// Create the client, server and database
let mut base_server = Server::new(rng);
Expand Down Expand Up @@ -302,7 +302,7 @@ fn test_core(
ClientMessage<'_, K1>,
ServerMessage<'_, K1>,
)> {
let mut rng = OsRng.unwrap_err();
let mut rng = SysRng.unwrap_err();

// ===== Augmentation Layer =====
// client initiates the augmentation phase
Expand Down
6 changes: 3 additions & 3 deletions aucpace/tests/test_key_agreement_strong.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg(all(feature = "alloc", feature = "rand", feature = "strong_aucpace"))]

use aucpace::{
Client, ClientMessage, OsRng, Result, Server, ServerMessage, StrongDatabase,
Client, ClientMessage, Result, Server, ServerMessage, StrongDatabase, SysRng,
client::{AuCPaceClientPreAug, AuCPaceClientRecvServerKey},
rand_core::TryRngCore,
server::{AuCPaceServerAugLayer, AuCPaceServerRecvClientKey},
Expand Down Expand Up @@ -235,7 +235,7 @@ fn test_key_agreement_prestablished_ssid_implicit_auth() -> Result<()> {

/// Perform the initialisation step for all tests
fn init() -> Result<(Client, Server, SingleUserDatabase)> {
let rng = OsRng.unwrap_err();
let rng = SysRng.unwrap_err();

// Create the client, server and database
let base_server = Server::new(rng);
Expand Down Expand Up @@ -269,7 +269,7 @@ fn test_core(
ClientMessage<'_, K1>,
ServerMessage<'_, K1>,
)> {
let mut rng = OsRng.unwrap_err();
let mut rng = SysRng.unwrap_err();

// ===== Augmentation Layer =====
// client initiates the augmentation phase
Expand Down
8 changes: 4 additions & 4 deletions aucpace/tests/test_key_agreement_strong_partial_aug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
))]

use aucpace::{
Client, ClientMessage, Error, OsRng, PartialAugDatabase, Result, Server, ServerMessage,
StrongDatabase,
Client, ClientMessage, Error, PartialAugDatabase, Result, Server, ServerMessage,
StrongDatabase, SysRng,
client::{AuCPaceClientPreAug, AuCPaceClientRecvServerKey},
rand_core::TryRngCore,
server::{AuCPaceServerAugLayer, AuCPaceServerRecvClientKey},
Expand Down Expand Up @@ -272,7 +272,7 @@ fn test_key_agreement_prestablished_ssid_implicit_auth() -> Result<()> {

/// Perform the initialisation step for all tests
fn init() -> Result<(Client, Server, SingleUserDatabase)> {
let rng = OsRng.unwrap_err();
let rng = SysRng.unwrap_err();

// Create the client, server and database
let mut base_server = Server::new(rng);
Expand Down Expand Up @@ -308,7 +308,7 @@ fn test_core(
ClientMessage<'_, K1>,
ServerMessage<'_, K1>,
)> {
let mut rng = OsRng.unwrap_err();
let mut rng = SysRng.unwrap_err();

// ===== Augmentation Layer =====
// client initiates the augmentation phase
Expand Down
2 changes: 1 addition & 1 deletion spake2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rust-version = "1.85"

[dependencies]
curve25519-dalek = { version = "5.0.0-pre.3", default-features = false, features = ["rand_core"] }
rand_core = { version = "0.10.0-rc-2", default-features = false }
rand_core = { version = "0.10.0-rc-3", default-features = false }
sha2 = { version = "0.11.0-rc.3", default-features = false }
hkdf = { version = "0.13.0-rc.3", default-features = false }

Expand Down
8 changes: 4 additions & 4 deletions spake2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ use curve25519_dalek::{edwards::EdwardsPoint as c2_Element, scalar::Scalar as c2
use rand_core::CryptoRng;

#[cfg(feature = "rand")]
pub use rand::rngs::OsRng;
pub use rand::rngs::SysRng;

#[cfg(feature = "rand")]
use rand::TryRngCore;
Expand Down Expand Up @@ -323,7 +323,7 @@ impl<G: Group> Spake2<G> {
#[cfg(feature = "rand")]
#[must_use]
pub fn start_a(password: &Password, id_a: &Identity, id_b: &Identity) -> (Self, Vec<u8>) {
Self::start_a_with_rng(password, id_a, id_b, OsRng.unwrap_mut())
Self::start_a_with_rng(password, id_a, id_b, SysRng.unwrap_mut())
}

/// Start with identity `idB`.
Expand All @@ -332,7 +332,7 @@ impl<G: Group> Spake2<G> {
#[cfg(feature = "rand")]
#[must_use]
pub fn start_b(password: &Password, id_a: &Identity, id_b: &Identity) -> (Self, Vec<u8>) {
Self::start_b_with_rng(password, id_a, id_b, OsRng.unwrap_mut())
Self::start_b_with_rng(password, id_a, id_b, SysRng.unwrap_mut())
}

/// Start with symmetric identity.
Expand All @@ -341,7 +341,7 @@ impl<G: Group> Spake2<G> {
#[cfg(feature = "rand")]
#[must_use]
pub fn start_symmetric(password: &Password, id_s: &Identity) -> (Self, Vec<u8>) {
Self::start_symmetric_with_rng(password, id_s, OsRng.unwrap_mut())
Self::start_symmetric_with_rng(password, id_s, SysRng.unwrap_mut())
}

/// Start with identity `idA` and the provided cryptographically secure RNG.
Expand Down