1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
pub(crate) mod api;
pub mod b64;
pub mod hkdf;
pub mod key_set;
pub mod sig;

// Re-export the cryptographically secure random bytes generator
#[cfg(feature = "crypto-openssl")]
pub use openssl::rand::rand_bytes;

/// Cryptographically secure random bytes generator.
#[cfg(feature = "crypto-ring")]
pub fn rand_bytes(buf: &mut [u8]) -> Result<(), ring::error::Unspecified> {
    use ring::rand::{SecureRandom, SystemRandom};
    SystemRandom::new().fill(buf)
}