diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2022-05-11 13:21:58 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2022-05-11 15:55:59 +0200 |
commit | 523cfd7845fd8141293b5dbe63e630428e9ac90d (patch) | |
tree | 2206da57847816dea89d0adfd1d7711ea854977e /openpgp/src/crypto/mod.rs | |
parent | dfa22b657ba582cb03c0895d56b1513d4b9b8cd2 (diff) |
openpgp: Add explicit forwarder for crypto::random.
- This harmonizes the docstring across the different backends.
Also, it avoids monomorphization of the backend functions.
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 |