ruby-changes:40732
From: kosaki <ko1@a...>
Date: Tue, 1 Dec 2015 05:29:28 +0900 (JST)
Subject: [ruby-changes:40732] kosaki:r52811 (trunk): * lib/securerandom.rb (SecureRandom::gen_random): use /dev/urandom
kosaki 2015-12-01 05:29:22 +0900 (Tue, 01 Dec 2015) New Revision: 52811 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52811 Log: * lib/securerandom.rb (SecureRandom::gen_random): use /dev/urandom for initialize OpenSSL's rand. Modified files: trunk/ChangeLog trunk/lib/securerandom.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 52810) +++ ChangeLog (revision 52811) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Oct 22 00:12:33 2015 KOSAKI Motohiro <kosaki.motohiro@g...> + + * 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@g...> * ext/openssl/ossl_rand.c (ossl_rand_bytes): RAND_bytes could Index: lib/securerandom.rb =================================================================== --- lib/securerandom.rb (revision 52810) +++ lib/securerandom.rb (revision 52811) @@ -56,6 +56,10 @@ module SecureRandom https://github.com/ruby/ruby/blob/trunk/lib/securerandom.rb#L56 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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/