ossp-pkg/uuid/uuid_prng.c 1.19 -> 1.20
--- uuid_prng.c 2008/03/06 12:14:49 1.19
+++ uuid_prng.c 2008/06/04 17:27:27 1.20
@@ -37,6 +37,11 @@
#include <time.h>
#include <sys/time.h>
#include <fcntl.h>
+#if defined(WIN32)
+#define WINVER 0x0500
+#include <windows.h>
+#include <wincrypt.h>
+#endif
/* own headers (part 2/2) */
#include "uuid_time.h"
@@ -114,6 +119,9 @@
size_t md5_len;
int retries;
int i;
+#if defined(WIN32)
+ HCRYPTPROV hProv;
+#endif
/* sanity check argument(s) */
if (prng == NULL || data_len == 0)
@@ -138,6 +146,12 @@
p += (unsigned int)i;
}
}
+#if defined(WIN32)
+ else {
+ if (CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, 0))
+ CryptGenRandom(hProv, n, p);
+ }
+#endif
/* approach 2: try to gather data via weaker libc PRNG API. */
while (n > 0) {
|
|