From bebd26d89c371ca7d546949b4a9c2e731d54dcae Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sun, 25 Jan 2026 12:58:45 -0700 Subject: [PATCH] crypto-common: add `UnwrapSysRng` alias Though I think the `Generate` trait covers a lot of use cases, for anyone who wants to use `SysRng` with `CryptoRng` this is a little more convenient than importing both `SysRng` and `Unwrap` and assembling it yourself. --- crypto-common/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crypto-common/src/lib.rs b/crypto-common/src/lib.rs index 164db413f..0a1cedfaa 100644 --- a/crypto-common/src/lib.rs +++ b/crypto-common/src/lib.rs @@ -20,7 +20,7 @@ pub use hybrid_array as array; pub use hybrid_array::typenum; #[cfg(feature = "getrandom")] -pub use getrandom; +pub use getrandom::{self, SysRng}; #[cfg(feature = "rand_core")] pub use {generate::Generate, rand_core}; @@ -33,6 +33,10 @@ use hybrid_array::{ #[cfg(feature = "rand_core")] use rand_core::CryptoRng; +/// [`CryptoRng`] interface for the system's preferred random number source that panics on error. +#[cfg(feature = "getrandom")] +pub type UnwrapSysRng = rand_core::UnwrapErr; + /// Block on which [`BlockSizeUser`] implementors operate. pub type Block = Array::BlockSize>;