From 1acea95ced239ae9329c0fbbc66dff8e1ad7a89e Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Thu, 18 Mar 2021 17:36:53 -0400 Subject: [PATCH] fix issue #1562 * use csrng for std::shuffle --- llarp/router/rc_lookup_handler.cpp | 3 +-- llarp/service/outbound_context.cpp | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/llarp/router/rc_lookup_handler.cpp b/llarp/router/rc_lookup_handler.cpp index bb1e02e1d..12b8b1beb 100644 --- a/llarp/router/rc_lookup_handler.cpp +++ b/llarp/router/rc_lookup_handler.cpp @@ -270,8 +270,7 @@ namespace llarp if (lookupRouters.size() > LookupPerTick) { - static std::mt19937_64 rng{llarp::randint()}; - std::shuffle(lookupRouters.begin(), lookupRouters.end(), rng); + std::shuffle(lookupRouters.begin(), lookupRouters.end(), CSRNG{}); lookupRouters.resize(LookupPerTick); } diff --git a/llarp/service/outbound_context.cpp b/llarp/service/outbound_context.cpp index 28370f042..86369bddb 100644 --- a/llarp/service/outbound_context.cpp +++ b/llarp/service/outbound_context.cpp @@ -410,9 +410,7 @@ namespace llarp std::vector intros = currentIntroSet.I; if (intros.size() > 1) { - std::random_device rd; - std::mt19937 g(rd()); - std::shuffle(intros.begin(), intros.end(), g); + std::shuffle(intros.begin(), intros.end(), CSRNG{}); } // to find a intro on the same router as before that is newer