summaryrefslogtreecommitdiffstats
path: root/random.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-18 00:07:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-18 00:07:07 +0000
commit9b63cf3ea0a6cbcaac79cab2c5c5cbdd97a3d84b (patch)
tree271786db12747eec021cf7c26961a22c5e627f8f /random.c
parent036158baa2b077916917584ebf5d29adecc97f5f (diff)
downloadruby-9b63cf3ea0a6cbcaac79cab2c5c5cbdd97a3d84b.tar.gz
ruby-9b63cf3ea0a6cbcaac79cab2c5c5cbdd97a3d84b.tar.xz
ruby-9b63cf3ea0a6cbcaac79cab2c5c5cbdd97a3d84b.zip
* random.c (fill_random_seed): use cryptographic service on Windows.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@24187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r--random.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/random.c b/random.c
index f67b65f2b..8013a51d0 100644
--- a/random.c
+++ b/random.c
@@ -389,6 +389,8 @@ fill_random_seed(unsigned int seed[DEFAULT_SEED_CNT])
#if USE_DEV_URANDOM
int fd;
struct stat statbuf;
+#elif defined(_WIN32)
+ HCRYPTPROV prov;
#endif
memset(seed, 0, DEFAULT_SEED_LEN);
@@ -410,6 +412,11 @@ fill_random_seed(unsigned int seed[DEFAULT_SEED_CNT])
}
close(fd);
}
+#elif defined(_WIN32)
+ if (CryptAcquireContext(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
+ CryptGenRandom(prov, DEFAULT_SEED_LEN, seed);
+ CryptReleaseContext(prov, 0);
+ }
#endif
gettimeofday(&tv, 0);