aurora/random.rs
1use super::{named, ProviderInstance};
2pub use rand::rand_core::CryptoRng;
3
4// we re-export `rand` so consumers can bring into scope the needed traits from the appropriate
5// `rand` crate version
6pub(crate) use ::rand;
7
8// This module is for convenience, so consumers can just `use crate::random::prelude::*` instead of
9// discovering which traits from `rand` they need.
10pub mod prelude {
11 #![allow(unused_imports)]
12
13 pub(crate) use super::rand::TryRng;
14 pub(crate) use super::CryptoRng;
15}
16
17impl<'a> ProviderInstance<'a> {
18 #[named]
19 pub fn get_rng(&self) -> impl CryptoRng {
20 trace!(target: log_target!(), "Called ");
21
22 // TODO: we should likely build an rng around OpenSSL's rand
23 // the core dispatch table has these:
24 // https://github.com/openssl/openssl/blob/openssl-4.0.0/doc/internal/man3/ossl_rand_get_entropy.pod
25
26 let rng = rand::rng();
27
28 return rng;
29 }
30}