Project

General

Profile

« Previous | Next » 

Revision abae70d6

Added by shyouhei (Shyouhei Urabe) about 7 years ago

SecureRandom should try /dev/urandom first [Bug #9569]

    * random.c (InitVM_Random): rename Random.raw_seed to
      Random.urandom.  A quick search seems there are no practical use
      of this method than securerandom.rb so I think it's OK to rename
      but if there are users of it, this hunk is subject to revert.

    * test/ruby/test_rand.rb (TestRand#test_urandom): test for it.

    * lib/securerandom.rb (SecureRandom.gen_random): Prefer OS-
      provided CSPRNG if available. Otherwise falls back to OpenSSL.
      Current preference is:

      1. CSPRNG routine that the OS has; one of
         - getrandom(2),
         - arc4random(3), or
         - CryptGenRandom()
      2. /dev/urandom device
      3. OpenSSL's RAND_bytes(3)

      If none of above random number generators are available, you
      cannot use this module.  An exception is raised that case.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e