summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--lib/securerandom.rb8
2 files changed, 9 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index fe981ee..ede8c38 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Nov 9 05:00:23 2014 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * lib/securerandom.rb (initialize): call the special method for Win32
+ before cheking `/dev/urandom` because we know windows doesn't have it.
+
Sun Nov 9 04:01:46 2014 NAKAMURA Usaku <usa@ruby-lang.org>
* lib/securerandom.rb (SecureRandom::AdvApi32): split from `initialize`.
diff --git a/lib/securerandom.rb b/lib/securerandom.rb
index 5440dba..a0f7b13 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