[前][次][番号順一覧][スレッド一覧]

ruby-changes:42070

From: naruse <ko1@a...>
Date: Thu, 17 Mar 2016 15:01:17 +0900 (JST)
Subject: [ruby-changes:42070] naruse:r54144 (trunk): * lib/securerandom.rb (gen_random): to avoid blocking on Windows.

naruse	2016-03-17 15:01:11 +0900 (Thu, 17 Mar 2016)

  New Revision: 54144

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54144

  Log:
    * 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

  Modified files:
    trunk/ChangeLog
    trunk/lib/securerandom.rb
Index: lib/securerandom.rb
===================================================================
--- lib/securerandom.rb	(revision 54143)
+++ lib/securerandom.rb	(revision 54144)
@@ -48,7 +48,7 @@ end https://github.com/ruby/ruby/blob/trunk/lib/securerandom.rb#L48
 #
 
 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 = $$
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 54143)
+++ ChangeLog	(revision 54144)
@@ -1,3 +1,21 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Mar 17 11:51:48 2016  NARUSE, Yui  <naruse@r...>
+
+	* 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@i...>
 
 	* enc/unicode.c: Fixed two macro definitions.

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]