diff options
| author | jhurst <jhurst@cinecert.com> | 2006-09-23 23:47:17 +0000 |
|---|---|---|
| committer | jhurst <> | 2006-09-23 23:47:17 +0000 |
| commit | 72e5392ca11c06a1ac0732c71f86df0d9a712ce3 (patch) | |
| tree | 25c9f223d62700409fbe883865dc5a54677726a0 /src/KM_prng.cpp | |
| parent | 1cd511e77b968ba068c59f4771cb67810e4ba4c4 (diff) | |
1.1.9 release a
Diffstat (limited to 'src/KM_prng.cpp')
| -rwxr-xr-x | src/KM_prng.cpp | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/src/KM_prng.cpp b/src/KM_prng.cpp index 01d4b1d..094ee1b 100755 --- a/src/KM_prng.cpp +++ b/src/KM_prng.cpp @@ -41,31 +41,10 @@ using namespace Kumu; #ifdef KM_WIN32 - -// make up a byte by sampling the perf counter LSB -static byte_t get_perf_byte(byte_t carry) -{ - LARGE_INTEGER ticks; - byte_t sha_buf[20]; - SHA_CTX SHA; - SHA1_Init(&SHA); - SHA1_Update(&SHA, &carry, sizeof(byte_t)); - - for ( int i = 0; i < 128; i++ ) - { - QueryPerformanceCounter(&ticks); - SHA1_Update(&SHA, &ticks.LowPart, sizeof(ticks.LowPart)); - } - - SHA1_Final(sha_buf, &SHA); - return sha_buf[0]; -} - +# include <wincrypt.h> #else // KM_WIN32 - -#include <KM_fileio.h> +# include <KM_fileio.h> const char* DEV_URANDOM = "/dev/urandom"; - #endif // KM_WIN32 @@ -95,11 +74,9 @@ public: AutoMutex Lock(m_Lock); #ifdef KM_WIN32 - for ( ui32_t i = 0; i < RNG_KEY_SIZE; i++ ) - { - byte_t carry = ( i == 0 ) ? 0xa3 : rng_key[i-1]; - rng_key[i] = get_perf_byte(carry); - } + HCRYPTPROV hProvider = 0; + CryptAcquireContext(&hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); + CryptGenRandom(hProvider, RNG_KEY_SIZE, rng_key); #else // KM_WIN32 // on POSIX systems we simply read some seed from /dev/urandom FileReader URandom; |
