summaryrefslogtreecommitdiffstats
path: root/openpgp/src/crypto/backend
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2022-05-11 13:21:58 +0200
committerJustus Winter <justus@sequoia-pgp.org>2022-05-11 15:55:59 +0200
commit523cfd7845fd8141293b5dbe63e630428e9ac90d (patch)
tree2206da57847816dea89d0adfd1d7711ea854977e /openpgp/src/crypto/backend
parentdfa22b657ba582cb03c0895d56b1513d4b9b8cd2 (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/backend')
-rw-r--r--openpgp/src/crypto/backend/cng.rs4
-rw-r--r--openpgp/src/crypto/backend/nettle.rs12
-rw-r--r--openpgp/src/crypto/backend/rust.rs9
3 files changed, 6 insertions, 19 deletions
diff --git a/openpgp/src/crypto/backend/cng.rs b/openpgp/src/crypto/backend/cng.rs
index 8bf01b02..f964756a 100644
--- a/openpgp/src/crypto/backend/cng.rs
+++ b/openpgp/src/crypto/backend/cng.rs
@@ -11,9 +11,9 @@ pub mod hash;
pub mod symmetric;
/// Fills the given buffer with random data.
-pub fn random<B: AsMut<[u8]>>(mut buf: B) {
+pub fn random(buf: &mut [u8]) {
RandomNumberGenerator::system_preferred()
- .gen_random(buf.as_mut())
+ .gen_random(buf)
.expect("system-preferred RNG not to fail")
}
diff --git a/openpgp/src/crypto/backend/nettle.rs b/openpgp/src/crypto/backend/nettle.rs
index 9bf737c0..79497a66 100644
--- a/openpgp/src/crypto/backend/nettle.rs
+++ b/openpgp/src/crypto/backend/nettle.rs
@@ -11,16 +11,8 @@ pub mod hash;
pub mod symmetric;
/// 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) {
- Yarrow::default().random(buf.as_mut());
+pub fn random(buf: &mut [u8]) {
+ Yarrow::default().random(buf);
}
impl PublicKeyAlgorithm {
diff --git a/openpgp/src/crypto/backend/rust.rs b/openpgp/src/crypto/backend/rust.rs
index 1bc6bf05..06b1da03 100644
--- a/openpgp/src/crypto/backend/rust.rs
+++ b/openpgp/src/crypto/backend/rust.rs
@@ -10,16 +10,11 @@ pub mod hash;
pub mod symmetric;
/// 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.
-pub fn random<B: AsMut<[u8]>>(mut buf: B) {
+pub fn random(buf: &mut [u8]) {
use rand07::rngs::OsRng;
use rand07::RngCore;
- OsRng.fill_bytes(buf.as_mut())
+ OsRng.fill_bytes(buf)
}
impl PublicKeyAlgorithm {