From baf6f108b94f7e7b3a2ec12396e9bfbbd67c76ee Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Thu, 9 Apr 2020 23:21:10 +0200 Subject: openpgp: Move random generation to Nettle backend --- openpgp/src/crypto/backend/nettle.rs | 7 +++++++ openpgp/src/crypto/mod.rs | 7 +------ 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'openpgp/src/crypto') diff --git a/openpgp/src/crypto/backend/nettle.rs b/openpgp/src/crypto/backend/nettle.rs index 451774e2..5c0149fc 100644 --- a/openpgp/src/crypto/backend/nettle.rs +++ b/openpgp/src/crypto/backend/nettle.rs @@ -1 +1,8 @@ //! Implementation of Sequoia crypto API using the Nettle cryptographic library. + +use nettle::random::{Random, Yarrow}; + +/// Fills the given buffer with random data. +pub fn random>(mut buf: B) { + Yarrow::default().random(buf.as_mut()); +} diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs index 8d2e04fd..37285c63 100644 --- a/openpgp/src/crypto/mod.rs +++ b/openpgp/src/crypto/mod.rs @@ -5,7 +5,6 @@ use std::ops::{Deref, DerefMut}; use std::fmt; use buffered_reader::BufferedReader; -use nettle::random::{Random, Yarrow}; use crate::types::HashAlgorithm; use crate::Result; @@ -14,6 +13,7 @@ pub(crate) mod aead; mod asymmetric; pub use self::asymmetric::{Signer, Decryptor, KeyPair}; mod backend; +pub use backend::random; pub(crate) mod ecdh; pub mod hash; mod keygrip; @@ -25,11 +25,6 @@ pub use s2k::S2K; pub mod sexp; pub(crate) mod symmetric; -/// Fills the given buffer with random data. -pub fn random>(mut buf: B) { - Yarrow::default().random(buf.as_mut()); -} - /// Holds a session key. /// /// The session key is cleared when dropped. -- cgit v1.2.3