Check-in Number:
|
6001 | |
Date: |
2008-Jun-04 19:27:27 (local)
2008-Jun-04 17:27:27 (UTC) |
User: | rse |
Branch: | |
Comment: |
Improve PRNG under Win32 |
Tickets: |
|
Inspections: |
|
Files: |
|
ossp-pkg/uuid/ChangeLog 1.158 -> 1.159
--- ChangeLog 2008/03/07 13:52:41 1.158
+++ ChangeLog 2008/06/04 17:27:27 1.159
@@ -13,6 +13,9 @@
Changes between 1.6.1 and 1.6.2 (21-Feb-2008 to 06-Mar-2008)
+ o Improve PRNG under Win32.
+ [Hiroshi Saito]
+
o Consistently annotate "RFC-XXXX" with "IETF" to clearly
indicate from which standards body this comes from.
[Ralf S. Engelschall]
|
|
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) {
|
|