From 34e49627b77e5a2e800ec7cd709a63d5d49860b6 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 12 Aug 2019 00:11:41 -0400 Subject: [PATCH] Use C++ dynamic initialization if available --- osrng.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osrng.cpp b/osrng.cpp index 244bf74c..5d9b9b12 100644 --- a/osrng.cpp +++ b/osrng.cpp @@ -148,7 +148,11 @@ void NonblockingRng::GenerateBlock(byte *output, size_t size) { #ifdef CRYPTOPP_WIN32_AVAILABLE // Acquiring a provider is expensive. Do it once and retain the reference. +# if defined(CRYPTOPP_CXX11_DYNAMIC_INIT) + static const MicrosoftCryptoProvider hProvider = MicrosoftCryptoProvider(); +# else const MicrosoftCryptoProvider &hProvider = Singleton().Ref(); +# endif # if defined(USE_MS_CRYPTOAPI) if (!CryptGenRandom(hProvider.GetProviderHandle(), (DWORD)size, output)) throw OS_RNG_Err("CryptGenRandom");