tor-hscrypto: implement Rng.gen() for RendCookie

This commit is contained in:
Ian Jackson 2023-06-07 17:24:46 +01:00
parent dc95c7874a
commit a50016b3da
3 changed files with 8 additions and 0 deletions

1
Cargo.lock generated
View File

@ -4197,6 +4197,7 @@ dependencies = [
"humantime 2.1.0", "humantime 2.1.0",
"itertools", "itertools",
"paste", "paste",
"rand 0.8.5",
"rand_core 0.6.4", "rand_core 0.6.4",
"safelog", "safelog",
"serde", "serde",

View File

@ -21,6 +21,7 @@ derive_more = "0.99.3"
digest = "0.10.0" digest = "0.10.0"
itertools = "0.10.1" itertools = "0.10.1"
paste = "1" paste = "1"
rand = "0.8"
rand_core = "0.6.2" rand_core = "0.6.2"
safelog = { path = "../safelog", version = "0.3.1" } safelog = { path = "../safelog", version = "0.3.1" }
serde = { version = "1.0.103", features = ["derive"] } serde = { version = "1.0.103", features = ["derive"] }

View File

@ -91,3 +91,9 @@ define_bytes! {
#[derive(Copy, Clone, Debug, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct RendCookie([u8; REND_COOKIE_LEN]); pub struct RendCookie([u8; REND_COOKIE_LEN]);
} }
impl rand::distributions::Distribution<RendCookie> for rand::distributions::Standard {
fn sample<R: rand::Rng + ?Sized>(&self, rng: &mut R) -> RendCookie {
RendCookie(rng.gen::<[u8; REND_COOKIE_LEN]>().into())
}
}