Граф коммитов

43 Коммитов

Автор SHA1 Сообщение Дата
nobu b1adbd14e5 random.c: rand_random_number
* random.c (rand_random_number): add a method to return a random
  number like SecureRandom to Random::Formatter.
* lib/securerandom.rb (random_bytes): move to Random::Formatter,
  the base method of the module.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-14 03:20:04 +00:00
nobu 1f13a179d3 securerandom.rb: Random::Formatter
* lib/securerandom.rb (Random::Formatter): extract random number
  formatting methods into a module.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-14 03:02:32 +00:00
nobu eeeb7ae8c0 random.c: Random.raw_seed
* random.c (random_raw_seed): extract platform dependent random
  seed initialization function as a new method Random.raw_seed.
* lib/securerandom.rb (SecureRandom): use Random.raw_seed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-14 03:01:36 +00:00
hsbt 045de8a9c5 * lib/securerandom.rb: improve syntax and grammar of documentation.
[fix GH-796][ci skip] Patch by @Erol

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-02 06:36:00 +00:00
nobu 93ccab82c5 securerandom.rb: separate implementations
* lib/securerandom.rb (SecureRandom.gen_random): separate
  implementation details and select at the load time.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-09 03:16:24 +00:00
nobu 7d7bdcc5c6 securerandom.rb: fix substring of FormatMessage result
* lib/securerandom.rb: set the script encoding to make a string
  literal in SecureRandom::Kernel32.last_error_message single byte
  encoding so msg[] works in bytes, since FormatMessage() returns
  the size in TCHARs, not in characters.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-09 01:31:05 +00:00
usa dc79945a2b * 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
2014-11-08 20:01:24 +00:00
usa 6999a86600 * lib/securerandom.rb: more refactoring.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-08 19:59:01 +00:00
usa b2247be993 * lib/securerandom.rb (SecureRandom::AdvApi32): split from `initialize`.
thanks @zzak to remember it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-08 19:02:48 +00:00
usa 07f460829a * lib/securerandom.rb (SecureRandom.random_bytes): use fiddle directly
instead of using Win32API.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-04 12:20:59 +00:00
tenderlove 07308c4d30 * ext/dl/*: remove DL as it is replaced by Fiddle.
[Feature #5458] Thanks to Jonan Scheffler <jonanscheffler@gmail.com>
  for this patch

* test/dl/*: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-31 21:13:09 +00:00
glass 0a22f4c168 * lib/securerandom.rb: use OpenSSL::BN for performance improvement.
* benchmark/bm_securerandom.rb: benchmark script.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-08 11:00:47 +00:00
zzak 09c3f84566 * lib/securerandom.rb: [DOC] Add note on require for examples
Based on a patch by @schneems [Fixes GH-518] [ci skip]
  https://github.com/ruby/ruby/pull/518


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-31 21:12:49 +00:00
zzak d24903f063 commit miss from r43573
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-07 18:04:05 +00:00
zzak 9408bba58b * lib/securerandom.rb: [DOC] SecureRandom.hex length argument
[Fixes GH-394] Patch by @avdi https://github.com/ruby/ruby/pull/394


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-20 14:40:08 +00:00
akr 7a4feec795 * lib/securerandom.rb (random_bytes): Use Process.clock_gettime.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-31 05:07:56 +00:00
zzak 84247a63ce * lib/securerandom.rb: Refactor conditions by Rafal Chmiel
[Fixes GH-326] https://github.com/ruby/ruby/pull/326


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-11 04:01:47 +00:00
zzak e3436d2957 * lib/securerandom.rb: Update position of overview for RDoc
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-20 11:37:04 +00:00
akr c3c4ffa972 * lib/securerandom.rb (SecureRandom.random_bytes): Use
OpenSSL::Random.random_add instead of OpenSSL::Random.seed and
  specify 0.0 as the entropy.
  [ruby-core:47308] [Bug #6928]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-02 15:09:36 +00:00
akr 817a96a45d * lib/securerandom.rb: Don't use Array#to_s.
[ruby-core:52058] [Bug #7811] fixed by zzak (Zachary Scott).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-02 10:08:10 +00:00
shirosaki 3207af4cb8 lib/securerandom.rb: fix errors on Windows
* lib/securerandom.rb (SecureRandom.random_bytes):
  Use 64bit value as pointer for Windows x64 to fix SystemCallError.

* lib/securerandom.rb (SecureRandom.lastWin32ErrorMessage):
  Set proper encoding to avoid invalid byte sequence error.
  [ruby-core:47451] [Bug #6990]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-13 13:01:23 +00:00
akr e1ee200bf7 refine an error message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-07 11:15:46 +00:00
akr e76660caad * lib/securerandom.rb (random_bytes): call to_int method for the
argument at first.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-07 11:15:28 +00:00
akr a961a8edf0 * lib/securerandom.rb: show actual read length in an error message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-06 05:51:13 +00:00
akr 432a992aaf * lib/securerandom.rb (random_bytes): use IO#read instead of
IO#readpartial to make the intent more clear.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-02 11:54:52 +00:00
akr 31eb19bbb6 * lib/securerandom.rb: call OpenSSL::Random.seed at the
SecureRandom.random_bytes call.
  based on the patch by Masahiro Tomita.  [ruby-dev:44270] 


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-29 15:01:20 +00:00
akr 58bae71a7b * lib/securerandom.rb (SecureRandom.random_bytes): modify PRNG state
to prevent random number sequence repeatation at forked child
  process which has same pid.
  reported by Eric Wong.  [ruby-core:35765]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-13 09:36:48 +00:00
akr 7bda092ee8 update document.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-11 23:43:13 +00:00
akr c755baf85f update document.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-11 19:55:08 +00:00
akr 19b2909ee8 * random.c (fill_random_seed): don't use O_NOFOLLOW because
/dev/urandom is a symlink in OpenSolaris.

* lib/securerandom.rb (SecureRandom.random_bytes: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-05 15:04:38 +00:00
akr fb99416115 rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-19 20:21:19 +00:00
usa 971f2bb769 * lib/securerandom.rb (SecureRandom.random_bytes): return string should
be ASCII-8BIT.  [ruby-core:24640]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-31 09:03:09 +00:00
akr ebd2090d29 update rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-26 15:47:24 +00:00
akr 42d25de958 * lib/securerandom.rb (SecureRandom.urlsafe_base64): add optional
argument to add padding.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-06 14:36:33 +00:00
akr 1c2005fbf6 * lib/securerandom.rb (SecureRandom.urlsafe_base64): delete padding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-02 16:56:40 +00:00
akr 4ca8057c3e rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-01 12:59:59 +00:00
akr 357f66670c * lib/securerandom.rb (SecureRandom.urlsafe_base64): new method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-15 07:58:31 +00:00
nobu f10e2af1e6 * lib/securerandom.rb (SecureRandom.uuid): uses unpacked array
instead of string, because String#[] returns one length string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-29 04:16:17 +00:00
technorama 7dd1a098a6 * lib/securerandom.rb: new method SecureRandom#uuid
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-29 03:20:26 +00:00
technorama 4ca0782393 * lib/securerandom.rb: Add Win32 support.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-06 09:11:34 +00:00
akr 4ba1c80b9a * lib/securerandom.rb: documente updated.
suggested by NaHi.  [ruby-dev:30966]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-14 05:40:16 +00:00
akr 1b8a677b23 add document.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-10 02:47:41 +00:00
akr 52ec7cc543 * lib/securerandom.rb: renamed from lib/secrand.rb.
suggested by NaHi.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-10 01:42:51 +00:00