aboutsummaryrefslogtreecommitdiffstats
path: root/lib/securerandom.rb
Commit message (Collapse)AuthorAgeFilesLines
* random.c: use bytesnobu2016-05-101-0/+4
| | | | | | | * random.c (obj_random_bytes): base on bytes method instead of rand method, not to call toplevel rand method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb (gen_random): to avoid blocking on Windows.naruse2016-03-171-1/+1
| | | | | | | | | | | | | | | | | | | On Windows OpenSSL RAND_bytes (underlying implementation is RAND_poll in crypto/rand/rand_win.c) may be blocked at NetStatisticsGet. https://wiki.openssl.org/index.php/Random_Numbers#Windows_Issues Instead of this, use Random.raw_seed directory (whose implementation CryptGenRandom is one of the source of entropy of RAND_poll on Windows). https://wiki.openssl.org/index.php/Random_Numbers Note: CryptGenRandom function is PRNG and doesn't check its entropy, so it won't block. [Bug #12139] https://msdn.microsoft.com/ja-jp/library/windows/desktop/aa379942.aspx https://tools.ietf.org/html/rfc4086#section-7.1.3 https://eprint.iacr.org/2007/419.pdf http://www.cs.huji.ac.il/~dolev/pubs/thesis/msc-thesis-leo.pdf git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* securerandom.rb: remove to_s callnobu2016-03-041-2/+1
| | | | | | | * lib/securerandom.rb (gen_random): Array#join returns a String, no to_s is needed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* stdlib: avoid extra calls to eliminate "\n" from Base64normal2016-01-101-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | We may use the '0' (zero) to avoid adding the line feed. Furthermore, the '*' (asterisk) modifier is not needed for a single-element arrays. * ext/psych/lib/psych/visitors/yaml_tree.rb (visit_String): eliminate chomp * lib/net/http.rb (connect): eliminate delete * lib/net/http/header.rb (basic_encode): ditto * lib/net/imap.rb (authenticate): eliminate gsub (self.encode_utf7): shorten delete arg * lib/net/smtp.rb (base64_encode): eliminate gsub * lib/open-uri.rb (OpenURI.open_http): eliminate delete * lib/rss/rss.rb: ditto * lib/securerandom.rb (base64): ditto (urlsafe_base64): eliminate delete! * lib/webrick/httpauth/digestauth.rb (split_param_value): eliminate chop * lib/webrick/httpproxy.rb (do_CONNECT): eliminate delete (setup_upstream_proxy_authentication): ditto [ruby-core:72666] [Feature #11938] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb (SecureRandom::gen_random): use /dev/urandomkosaki2015-11-301-0/+4
| | | | | | for initialize OpenSSL's rand. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC]akr2015-11-161-0/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb: Remove indicator for "frozen_string_literal: true".akr2015-11-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib/pp.rb: Ditto. * lib/prettyprint.rb: Ditto. * lib/resolv.rb: Ditto. * lib/securerandom.rb: Ditto. * lib/tmpdir.rb: Ditto. * lib/unicode_normalize/tables.rb: Ditto. * test/net/ftp/test_buffered_socket.rb: Ditto. * test/net/ftp/test_mlsx_entry.rb: Ditto. * test/open-uri/test_open-uri.rb: Ditto. * test/open-uri/test_ssl.rb: Ditto. * test/pathname/test_pathname.rb: Ditto. * test/test_pp.rb: Ditto. * test/test_prettyprint.rb: Ditto. * tool/transcode-tblgen.rb: Ditto. * ext/pathname/lib/pathname.rb: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb: Specify frozen_string_literal: true.akr2015-10-181-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* random.c: rand_random_numbernobu2015-02-141-20/+27
| | | | | | | | | * 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
* securerandom.rb: Random::Formatternobu2015-02-141-8/+12
| | | | | | | * 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
* random.c: Random.raw_seednobu2015-02-141-76/+7
| | | | | | | | * 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
* * lib/securerandom.rb: improve syntax and grammar of documentation.hsbt2015-01-021-24/+31
| | | | | | [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
* securerandom.rb: separate implementationsnobu2014-11-091-14/+15
| | | | | | | * 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
* securerandom.rb: fix substring of FormatMessage resultnobu2014-11-091-0/+1
| | | | | | | | | * 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
* * lib/securerandom.rb (initialize): call the special method for Win32usa2014-11-081-4/+4
| | | | | | | 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
* * lib/securerandom.rb: more refactoring.usa2014-11-081-37/+46
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb (SecureRandom::AdvApi32): split from `initialize`.usa2014-11-081-33/+36
| | | | | | | thanks @zzak to remember it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb (SecureRandom.random_bytes): use fiddle directlyusa2014-11-041-4/+9
| | | | | | | instead of using Win32API. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/dl/*: remove DL as it is replaced by Fiddle.tenderlove2014-10-311-2/+2
| | | | | | | | | [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
* * lib/securerandom.rb: use OpenSSL::BN for performance improvement.glass2014-08-081-13/+21
| | | | | | * benchmark/bm_securerandom.rb: benchmark script. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb: [DOC] Add note on require for exampleszzak2014-01-311-0/+6
| | | | | | | | 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
* commit miss from r43573zzak2013-11-071-8/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb: [DOC] SecureRandom.hex length argumentzzak2013-09-201-3/+3
| | | | | | | [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
* * lib/securerandom.rb (random_bytes): Use Process.clock_gettime.akr2013-08-311-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb: Refactor conditions by Rafal Chmielzzak2013-07-111-5/+5
| | | | | | | [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
* * lib/securerandom.rb: Update position of overview for RDoczzak2013-05-201-27/+21
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb (SecureRandom.random_bytes): Useakr2013-04-021-1/+1
| | | | | | | | | | 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
* * lib/securerandom.rb: Don't use Array#to_s.akr2013-04-021-1/+1
| | | | | | | | [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
* lib/securerandom.rb: fix errors on Windowsshirosaki2012-09-131-4/+5
| | | | | | | | | | | * 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
* refine an error message.akr2012-05-071-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb (random_bytes): call to_int method for theakr2012-05-071-1/+1
| | | | | | | | argument at first. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb: show actual read length in an error message.akr2012-05-061-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb (random_bytes): use IO#read instead ofakr2012-01-021-1/+1
| | | | | | | | 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
* * lib/securerandom.rb: call OpenSSL::Random.seed at the akr2011-07-291-1/+1
| | | | | | | | 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
* * lib/securerandom.rb (SecureRandom.random_bytes): modify PRNG stateakr2011-06-131-0/+8
| | | | | | | | | 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
* update document.akr2010-09-111-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* update document.akr2010-09-111-10/+10
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (fill_random_seed): don't use O_NOFOLLOW becauseakr2010-02-051-1/+0
| | | | | | | | | | /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
* rdoc update.akr2009-08-191-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb (SecureRandom.random_bytes): return string shouldusa2009-07-311-1/+1
| | | | | | | | be ASCII-8BIT. [ruby-core:24640] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* update rdoc.akr2009-04-261-1/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb (SecureRandom.urlsafe_base64): add optionalakr2009-03-061-6/+13
| | | | | | | argument to add padding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb (SecureRandom.urlsafe_base64): delete padding.akr2009-03-021-3/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rdoc update.akr2009-03-011-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb (SecureRandom.urlsafe_base64): new method.akr2009-02-151-0/+53
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb (SecureRandom.uuid): uses unpacked arraynobu2009-01-291-5/+3
| | | | | | | 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
* * lib/securerandom.rb: new method SecureRandom#uuidtechnorama2009-01-291-0/+10
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb: Add Win32 support.technorama2008-01-061-2/+47
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/securerandom.rb: documente updated.akr2007-06-141-2/+2
| | | | | | | suggested by NaHi. [ruby-dev:30966] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add document.akr2007-06-101-0/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e