summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-02-24 17:49:19 +0100
committerJustus Winter <justus@sequoia-pgp.org>2020-02-24 17:49:19 +0100
commitb4537c39126a3dbed9fbe5e843b5d9a050acdad6 (patch)
tree6c655427e0a278e0b44c1b35a1ceb73210c43dfa
parent5f0f830149c8241285e4c4ae6bd97a9482b1da1c (diff)
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.
-rw-r--r--openpgp/src/crypto/mod.rs4
1 files changed, 1 insertions, 3 deletions
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<B: AsMut<[u8]>>(mut buf: B) {
- use std::cell::RefCell;
- thread_local!(static RNG: RefCell<Yarrow> = Default::default());
- RNG.with(|rng| rng.borrow_mut().random(buf.as_mut()));
+ Yarrow::default().random(buf.as_mut());
}
/// Holds a session key.