aboutsummaryrefslogtreecommitdiffstats
path: root/lib/securerandom.rb
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-08 20:01:24 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-08 20:01:24 +0000
commitdc79945a2ba8fb019431633eae6521df706a2ca8 (patch)
treeb159eb6a033fa719c0978ab3cbdba2781dc578f4 /lib/securerandom.rb
parent6999a86600fc1bdbfbe9d79d8bfb6f71eacfe489 (diff)
downloadruby-dc79945a2ba8fb019431633eae6521df706a2ca8.tar.gz
* lib/securerandom.rb (initialize): call the special method for Win32
before cheking `/dev/urandom` because we know windows doesn't have it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/securerandom.rb')
-rw-r--r--lib/securerandom.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/securerandom.rb b/lib/securerandom.rb
index 5440dbaad9..a0f7b13da8 100644
--- a/lib/securerandom.rb
+++ b/lib/securerandom.rb
@@ -119,6 +119,10 @@ module SecureRandom
return OpenSSL::Random.random_bytes(n)
end
+ if defined?(AdvApi32)
+ return AdvApi32.gen_random(n)
+ end
+
if !defined?(@has_urandom) || @has_urandom
flags = File::RDONLY
flags |= File::NONBLOCK if defined? File::NONBLOCK
@@ -140,10 +144,6 @@ module SecureRandom
end
end
- if defined?(AdvApi32)
- return AdvApi32.gen_random(n)
- end
-
raise NotImplementedError, "No random device"
end