From b4537c39126a3dbed9fbe5e843b5d9a050acdad6 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Mon, 24 Feb 2020 17:49:19 +0100 Subject: openpgp: De-optimize crypto::random. - Previously, we used a thread-local cache of the Yarrow CPRNG state. However, without fork(2)-detection this is not safe. For now, just initialize a fresh one on every invocation. --- openpgp/src/crypto/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'openpgp/src/crypto/mod.rs') diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs index 9b338f13..c93b3625 100644 --- a/openpgp/src/crypto/mod.rs +++ b/openpgp/src/crypto/mod.rs @@ -30,9 +30,7 @@ pub use self::asymmetric::{ /// Fills the given buffer with random data. pub fn random>(mut buf: B) { - use std::cell::RefCell; - thread_local!(static RNG: RefCell = Default::default()); - RNG.with(|rng| rng.borrow_mut().random(buf.as_mut())); + Yarrow::default().random(buf.as_mut()); } /// Holds a session key. -- cgit v1.2.3