mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
Use secure allocator for RNG state
This commit is contained in:
parent
cddb31bb0a
commit
f2e60ca985
1 changed files with 4 additions and 2 deletions
|
|
@ -19,6 +19,8 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
#include <support/allocators/secure.h>
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
@ -351,8 +353,8 @@ RNGState& GetRNGState() noexcept
|
||||||
{
|
{
|
||||||
// This C++11 idiom relies on the guarantee that static variable are initialized
|
// This C++11 idiom relies on the guarantee that static variable are initialized
|
||||||
// on first call, even when multiple parallel calls are permitted.
|
// on first call, even when multiple parallel calls are permitted.
|
||||||
static std::unique_ptr<RNGState> g_rng{new RNGState()};
|
static std::vector<RNGState, secure_allocator<RNGState>> g_rng(1);
|
||||||
return *g_rng;
|
return g_rng[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue