Skip to content

Commit

Permalink
Drop rand dependency in favor of getrandom (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
TroyNeubauer authored Aug 3, 2024
1 parent d089a0c commit e7f470b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ default-target = "x86_64-pc-windows-msvc"
targets = ["aarch64-pc-windows-msvc", "i686-pc-windows-msvc", "x86_64-pc-windows-msvc"]

[dependencies]
widestring = "0.4"
log = "0.4"
rand = "0.8"
bitflags = "2"

libloading = "0.8"
getrandom = "0.2.15"
ipnet = "2.3"
libloading = "0.8"
log = "0.4"
widestring = "0.4"
windows-sys = { version = "0.52", features = [
"Win32_Foundation",
"Win32_Networking",
Expand All @@ -32,7 +31,7 @@ windows-sys = { version = "0.52", features = [
]}

[dev-dependencies]
env_logger = "0.11"
base64 = "0.13"
x25519-dalek = { version = "2", default-features = false, features = ["static_secrets", "getrandom"] }
env_logger = "0.11"
ipnet = "2.3"
x25519-dalek = { version = "2", default-features = false, features = ["static_secrets", "getrandom"] }
4 changes: 2 additions & 2 deletions src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::sync::Arc;
use std::time::{Duration, SystemTime};

use ipnet::{IpNet, Ipv4Net, Ipv6Net};
use rand::Rng;
use widestring::U16CString;
use windows_sys::Win32::{
Foundation::{GetLastError, ERROR_MORE_DATA, ERROR_OBJECT_ALREADY_EXISTS, ERROR_SUCCESS},
Expand Down Expand Up @@ -149,7 +148,8 @@ impl Adapter {

let guid = guid.unwrap_or_else(|| {
let mut guid_bytes = [0u8; 16];
rand::thread_rng().fill(&mut guid_bytes);
getrandom::getrandom(&mut guid_bytes)
.expect("Failed to generate random bytes for guid");
u128::from_ne_bytes(guid_bytes)
});
//SAFETY: guid is a unique integer so transmuting either all zeroes or the user's preferred
Expand Down

0 comments on commit e7f470b

Please sign in to comment.