diff options
Diffstat (limited to 'openpgp/src/crypto/mod.rs')
-rw-r--r-- | openpgp/src/crypto/mod.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs index 2e40451a..e3cfa197 100644 --- a/openpgp/src/crypto/mod.rs +++ b/openpgp/src/crypto/mod.rs @@ -32,7 +32,6 @@ pub(crate) mod aead; mod asymmetric; pub use self::asymmetric::{Signer, Decryptor, KeyPair}; mod backend; -pub use backend::random; pub mod ecdh; pub mod hash; pub mod mem; @@ -44,6 +43,19 @@ pub(crate) mod symmetric; #[cfg(test)] mod tests; +/// Fills the given buffer with random data. +/// +/// Fills the given buffer with random data produced by a +/// cryptographically secure pseudorandom number generator (CSPRNG). +/// The output may be used as session keys or to derive long-term +/// cryptographic keys from. However, to create session keys, +/// consider using [`SessionKey::new`]. +/// +/// [`SessionKey::new`]: crate::crypto::SessionKey::new() +pub fn random<B: AsMut<[u8]>>(mut buf: B) { + backend::random(buf.as_mut()); +} + /// Holds a session key. /// /// The session key is cleared when dropped. Sequoia uses this type |