From 17712af318535095c11da73c6b6dbde228e70665 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Tue, 6 Feb 2024 18:58:31 +0000 Subject: [PATCH] Random: Try a little bit harder in the random bytes fallback path --- src/core/random_func.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/random_func.cpp b/src/core/random_func.cpp index 4f898333bd..1a92f4288b 100644 --- a/src/core/random_func.cpp +++ b/src/core/random_func.cpp @@ -10,6 +10,7 @@ #include "../stdafx.h" #include "random_func.hpp" #include "bitmath_func.hpp" +#include "hash_func.hpp" #include "../debug.h" #include #include @@ -143,7 +144,8 @@ void RandomBytesWithFallback(std::span buf) bool have_warned = warned_once.exchange(true); DEBUG(misc, have_warned ? 1 : 0, "Cryptographically-strong random generator unavailable; using fallback"); - for (uint i = 0; i < buf.size(); i++) { - buf[i] = static_cast(InteractiveRandom()); + for (uint i = 0; i < buf.size(); i ++) { + uint64_t current_time = static_cast(std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count()); + buf[i] = static_cast(SimpleHash64(current_time ^ InteractiveRandom())); } }