mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* random.c (fill_random_seed): use cryptographic service on Windows.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
924e2fcefa
commit
b12c5a85b4
2 changed files with 11 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
|||
Sat Jul 18 09:07:00 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* random.c (fill_random_seed): use cryptographic service on Windows.
|
||||
|
||||
Sat Jul 18 07:56:00 2009 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* ext/tk/lib/tk.rb: fail to create a widget object for an unknown
|
||||
|
|
7
random.c
7
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);
|
||||
|
|
Loading…
Reference in a new issue