Skip to content

Commit

Permalink
add a simple function to combine both provider and init steps
Browse files Browse the repository at this point in the history
  • Loading branch information
stevefan1999-personal committed Sep 25, 2024
1 parent 48f3f07 commit 6ed88f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ categories = ["cryptography", "no-std"]
keywords = ["rustls", "tls"]
edition = "2021"
rust-version = "1.75"
resolver = "1" # Hack to enable the `custom` feature of `getrandom`

# Ensure all dependencies + feats are mapped to crate features for correct usage
# default features often have std breaking no_std and potentially other unwanted
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ pub fn provider() -> CryptoProvider {
}
}

#[cfg(feature = "alloc")]
pub fn provider_and_init_rng(rng: Box<dyn RngCore + Send + Sync>) -> CryptoProvider {
init_randomness_source(rng);
provider()
}

// TODO: switch to ThinBox once it is available
#[cfg(feature = "alloc")]
static mut RNG: OnceCell<Box<dyn RngCore + Send + Sync>> = OnceCell::new();
Expand Down

0 comments on commit 6ed88f0

Please sign in to comment.