Skip to content

Commit

Permalink
zb: replace fastrand with rand
Browse files Browse the repository at this point in the history
As we need cryptographically secure randomness for cookie sha1 method
next.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
  • Loading branch information
elmarco committed Jan 21, 2021
1 parent 3c498ec commit d4c7666
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion zbus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ enumflags2 = { version = "0.6.4", features = ["serde"] }
serde-xml-rs = { version = "0.4.0", optional = true }
derivative = "2.1"
scoped-tls = "1.0.0"
fastrand = "1.2.4"
once_cell = "1.4.0"
async-io = "1.3.1"
futures-core = "0.3.8"
Expand All @@ -35,6 +34,7 @@ pollster = "0.2.0"
futures-util = { version = "0.3.8", default-features = false, features = ["sink", "std"] }
async-lock = "2.3.0"
hex = "0.4.2"
rand = "0.8.2"

[dev-dependencies]
zbus_polkit = { path = "../zbus_polkit", version = "1" }
Expand Down
4 changes: 2 additions & 2 deletions zbus/src/guid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ impl Guid {
///
/// [`Connection::new_unix_server`]: struct.Connection.html#method.new_unix_server
pub fn generate() -> Self {
let r: Vec<u32> = repeat_with(|| fastrand::u32(..)).take(3).collect();
let r: Vec<u32> = repeat_with(rand::random::<u32>).take(3).collect();
let r3 = match SystemTime::now().duration_since(UNIX_EPOCH) {
Ok(n) => n.as_secs() as u32,
Err(_) => fastrand::u32(..),
Err(_) => rand::random::<u32>(),
};

let s = format!("{:08x}{:08x}{:08x}{:08x}", r[0], r[1], r[2], r3);
Expand Down

0 comments on commit d4c7666

Please sign in to comment.