aboutsummaryrefslogtreecommitdiffstats
path: root/lib/securerandom.rb
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-30 20:29:22 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-30 20:29:22 +0000
commitc0033c08c9812c19eadd7aa5ce06d5f5ce656ced (patch)
tree2fa4b90eba141fda2271c28dddfc76198af20caa /lib/securerandom.rb
parent3aafb775e739ad571f57a35811da859c3b8d395c (diff)
downloadruby-c0033c08c9812c19eadd7aa5ce06d5f5ce656ced.tar.gz
* 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
Diffstat (limited to 'lib/securerandom.rb')
-rw-r--r--lib/securerandom.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/securerandom.rb b/lib/securerandom.rb
index f53087b954..b08b62b746 100644
--- a/lib/securerandom.rb
+++ b/lib/securerandom.rb
@@ -56,6 +56,10 @@ module SecureRandom
now = Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond)
ary = [now, @pid, pid]
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
end
return OpenSSL::Random.random_bytes(n)