That thread_specific_ptr was rubbish...
This commit is contained in:
@@ -23,7 +23,6 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <wincrypt.h>
|
#include <wincrypt.h>
|
||||||
|
|
||||||
#include <boost/thread.hpp>
|
|
||||||
#include <core/rand.h>
|
#include <core/rand.h>
|
||||||
|
|
||||||
class CryptData
|
class CryptData
|
||||||
@@ -43,21 +42,19 @@ public:
|
|||||||
}
|
}
|
||||||
~CryptData()
|
~CryptData()
|
||||||
{
|
{
|
||||||
if (cryptProvider) CryptReleaseContext(cryptProvider, 0);
|
if (cryptProvider)
|
||||||
|
CryptReleaseContext(cryptProvider, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
HCRYPTPROV cryptProvider;
|
HCRYPTPROV cryptProvider;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static CryptData g_cryptData;
|
||||||
|
|
||||||
void
|
void
|
||||||
RandomBytes(unsigned char *buf, unsigned size)
|
RandomBytes(unsigned char *buf, unsigned size)
|
||||||
{
|
{
|
||||||
static boost::thread_specific_ptr<CryptData> m_cryptData;
|
HCRYPTPROV provider = g_cryptData.cryptProvider;
|
||||||
|
|
||||||
if (!m_cryptData.get())
|
|
||||||
m_cryptData.reset(new CryptData);
|
|
||||||
|
|
||||||
HCRYPTPROV provider = m_cryptData.get()->cryptProvider;
|
|
||||||
|
|
||||||
if (provider)
|
if (provider)
|
||||||
::CryptGenRandom(provider, size, buf);
|
::CryptGenRandom(provider, size, buf);
|
||||||
|
|||||||
Reference in New Issue
Block a user