aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_rand.rb
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-20 08:00:00 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-20 08:00:00 +0000
commit036b0d1994d2e5718fcdc08d9ddb9be960815dc0 (patch)
tree3de590fcf8f22217987675fbc5eea399597c8fca /test/ruby/test_rand.rb
parent473d58199de5e8e751c9d841c80ede581c16993b (diff)
downloadruby-036b0d1994d2e5718fcdc08d9ddb9be960815dc0.tar.gz
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
Diffstat (limited to 'test/ruby/test_rand.rb')
-rw-r--r--test/ruby/test_rand.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/ruby/test_rand.rb b/test/ruby/test_rand.rb
index 46d10f8386..79befa8f04 100644
--- a/test/ruby/test_rand.rb
+++ b/test/ruby/test_rand.rb
@@ -550,9 +550,9 @@ END
End
end
- def test_raw_seed
+ def test_urandom
[0, 1, 100].each do |size|
- v = Random.raw_seed(size)
+ v = Random.urandom(size)
assert_kind_of(String, v)
assert_equal(size, v.bytesize)
end