aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-17 06:01:11 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-17 06:01:11 +0000
commit6545327e24c0efc7bb0cb32cd2043d79ea365790 (patch)
tree86888bbc42e83f4550ae9f91e839fef383bdd328
parent6555077aa00c9ca4bcb298392a615f729e15676a (diff)
downloadruby-6545327e24c0efc7bb0cb32cd2043d79ea365790.tar.gz
* lib/securerandom.rb (gen_random): to avoid blocking on Windows.
On Windows OpenSSL RAND_bytes (underlying implementation is RAND_poll in crypto/rand/rand_win.c) may be blocked at NetStatisticsGet. https://wiki.openssl.org/index.php/Random_Numbers#Windows_Issues Instead of this, use Random.raw_seed directory (whose implementation CryptGenRandom is one of the source of entropy of RAND_poll on Windows). https://wiki.openssl.org/index.php/Random_Numbers Note: CryptGenRandom function is PRNG and doesn't check its entropy, so it won't block. [Bug #12139] https://msdn.microsoft.com/ja-jp/library/windows/desktop/aa379942.aspx https://tools.ietf.org/html/rfc4086#section-7.1.3 https://eprint.iacr.org/2007/419.pdf http://www.cs.huji.ac.il/~dolev/pubs/thesis/msc-thesis-leo.pdf git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog18
-rw-r--r--lib/securerandom.rb2
2 files changed, 19 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 96fc0a96b4..51852a24d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+Thu Mar 17 11:51:48 2016 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * lib/securerandom.rb (gen_random): to avoid blocking on Windows.
+ On Windows OpenSSL RAND_bytes (underlying implementation is
+ RAND_poll in crypto/rand/rand_win.c) may be blocked at
+ NetStatisticsGet.
+ https://wiki.openssl.org/index.php/Random_Numbers#Windows_Issues
+ Instead of this, use Random.raw_seed directory (whose implementation
+ CryptGenRandom is one of the source of
+ entropy of RAND_poll on Windows).
+ https://wiki.openssl.org/index.php/Random_Numbers
+ Note: CryptGenRandom function is PRNG and doesn't check its entropy,
+ so it won't block. [Bug #12139]
+ https://msdn.microsoft.com/ja-jp/library/windows/desktop/aa379942.aspx
+ https://tools.ietf.org/html/rfc4086#section-7.1.3
+ https://eprint.iacr.org/2007/419.pdf
+ http://www.cs.huji.ac.il/~dolev/pubs/thesis/msc-thesis-leo.pdf
+
Thu Mar 17 12:09:00 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
* enc/unicode.c: Fixed two macro definitions.
diff --git a/lib/securerandom.rb b/lib/securerandom.rb
index c2eddbd5a3..d8afc7d01b 100644
--- a/lib/securerandom.rb
+++ b/lib/securerandom.rb
@@ -48,7 +48,7 @@ end
#
module SecureRandom
- if defined? OpenSSL::Random
+ if defined?(OpenSSL::Random) && /mswin|mingw/ !~ RUBY_PLATFORM
def self.gen_random(n)
@pid = 0 unless defined?(@pid)
pid = $$