mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/securerandom.rb (SecureRandom::gen_random): use /dev/urandom
for initialize OpenSSL's rand. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
07083767e9
commit
7104a473ea
2 changed files with 9 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Thu Oct 22 00:12:33 2015 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
|
* lib/securerandom.rb (SecureRandom::gen_random): use /dev/urandom
|
||||||
|
for initialize OpenSSL's rand.
|
||||||
|
|
||||||
Wed Oct 21 12:10:04 2015 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Wed Oct 21 12:10:04 2015 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* ext/openssl/ossl_rand.c (ossl_rand_bytes): RAND_bytes could
|
* ext/openssl/ossl_rand.c (ossl_rand_bytes): RAND_bytes could
|
||||||
|
|
|
@ -56,6 +56,10 @@ module SecureRandom
|
||||||
now = Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond)
|
now = Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond)
|
||||||
ary = [now, @pid, pid]
|
ary = [now, @pid, pid]
|
||||||
OpenSSL::Random.random_add(ary.join("").to_s, 0.0)
|
OpenSSL::Random.random_add(ary.join("").to_s, 0.0)
|
||||||
|
seed = Random.raw_seed(16)
|
||||||
|
if (seed)
|
||||||
|
OpenSSL::Random.random_add(seed, 16)
|
||||||
|
end
|
||||||
@pid = pid
|
@pid = pid
|
||||||
end
|
end
|
||||||
return OpenSSL::Random.random_bytes(n)
|
return OpenSSL::Random.random_bytes(n)
|
||||||
|
|
Loading…
Add table
Reference in a new issue