From a27456506d564cdc9cfb09d284d3bd34243b301d Mon Sep 17 00:00:00 2001 From: Vincent Ollivier Date: Sun, 28 Aug 2022 20:20:39 +0200 Subject: [PATCH 1/2] Add more bytes to RNG seed --- src/sys/random.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sys/random.rs b/src/sys/random.rs index f93f1086..df093165 100644 --- a/src/sys/random.rs +++ b/src/sys/random.rs @@ -42,6 +42,8 @@ pub fn get_u64() -> u64 { // FIXME: RDRAND instruction is not available on old CPUs seed[0..8].clone_from_slice(&sys::clock::realtime().to_be_bytes()); seed[8..16].clone_from_slice(&sys::clock::uptime().to_be_bytes()); + seed[16..24].clone_from_slice(&sys::time::ticks().to_be_bytes()); + seed[24..32].clone_from_slice(&sys::time::ticks().to_be_bytes()); } let mut rng = Hc128Rng::from_seed(seed); rng.next_u64() From 12957c90f4759364625b727323de7da0bb8fdd76 Mon Sep 17 00:00:00 2001 From: Vincent Ollivier Date: Sun, 28 Aug 2022 20:21:49 +0200 Subject: [PATCH 2/2] Reorder seed sources --- src/sys/random.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sys/random.rs b/src/sys/random.rs index df093165..db9562b7 100644 --- a/src/sys/random.rs +++ b/src/sys/random.rs @@ -40,9 +40,9 @@ pub fn get_u64() -> u64 { } } else { // FIXME: RDRAND instruction is not available on old CPUs - seed[0..8].clone_from_slice(&sys::clock::realtime().to_be_bytes()); - seed[8..16].clone_from_slice(&sys::clock::uptime().to_be_bytes()); - seed[16..24].clone_from_slice(&sys::time::ticks().to_be_bytes()); + seed[0..8].clone_from_slice(&sys::time::ticks().to_be_bytes()); + seed[8..16].clone_from_slice(&sys::clock::realtime().to_be_bytes()); + seed[16..24].clone_from_slice(&sys::clock::uptime().to_be_bytes()); seed[24..32].clone_from_slice(&sys::time::ticks().to_be_bytes()); } let mut rng = Hc128Rng::from_seed(seed);