<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/lib/securerandom.rb, branch v3_0_4</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>Make SecureRandom support Ractor</title>
<updated>2020-09-09T19:45:43+00:00</updated>
<author>
<name>Aaron Patterson</name>
<email>tenderlove@ruby-lang.org</email>
</author>
<published>2020-09-05T00:32:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=475c8701d74ebebefb2f53052cde1a5effb4cb81'/>
<id>475c8701d74ebebefb2f53052cde1a5effb4cb81</id>
<content type='text'>
SecureRandom lazily defines `get_random`.  Accessing the mutex to define
the `get_random` method is not supported inside a Ractor.  This commit
defines `gen_random` when `securerandom` is required and makes it
suppore Ractor (as well as thread safe).

Here is a test program:

```ruby
require "securerandom"

r = Ractor.new do
  loop do
    Ractor.yield SecureRandom.hex
  end
end

p r.take
```

Before this commit:

```
$ make runruby
./miniruby -I./lib -I. -I.ext/common  ./tool/runruby.rb --extout=.ext  -- --disable-gems ./test.rb
&lt;internal:ractor&gt;:38: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
/Users/aaron/git/ruby/lib/securerandom.rb:94:in `gen_random': can not access instance variables of classes/modules from non-main Ractors (RuntimeError)
&lt;internal:ractor&gt;:124:in `take': thrown by remote Ractor. (Ractor::RemoteError)
	from ./test.rb:9:in `&lt;main&gt;'
/Users/aaron/git/ruby/lib/securerandom.rb:94:in `gen_random': can not access instance variables of classes/modules from non-main Ractors (RuntimeError)
	from /Users/aaron/git/ruby/lib/securerandom.rb:155:in `random_bytes'
	from /Users/aaron/git/ruby/lib/securerandom.rb:176:in `hex'
	from ./test.rb:5:in `block (2 levels) in &lt;main&gt;'
	from ./test.rb:4:in `loop'
	from ./test.rb:4:in `block in &lt;main&gt;'
make: *** [runruby] Error
```

After this commit:

```
$ make runruby
./miniruby -I./lib -I. -I.ext/common  ./tool/runruby.rb --extout=.ext  -- --disable-gems ./test.rb
&lt;internal:ractor&gt;:38: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
"3fc8885157e3911bab4b5d7619bb0308"
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
SecureRandom lazily defines `get_random`.  Accessing the mutex to define
the `get_random` method is not supported inside a Ractor.  This commit
defines `gen_random` when `securerandom` is required and makes it
suppore Ractor (as well as thread safe).

Here is a test program:

```ruby
require "securerandom"

r = Ractor.new do
  loop do
    Ractor.yield SecureRandom.hex
  end
end

p r.take
```

Before this commit:

```
$ make runruby
./miniruby -I./lib -I. -I.ext/common  ./tool/runruby.rb --extout=.ext  -- --disable-gems ./test.rb
&lt;internal:ractor&gt;:38: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
/Users/aaron/git/ruby/lib/securerandom.rb:94:in `gen_random': can not access instance variables of classes/modules from non-main Ractors (RuntimeError)
&lt;internal:ractor&gt;:124:in `take': thrown by remote Ractor. (Ractor::RemoteError)
	from ./test.rb:9:in `&lt;main&gt;'
/Users/aaron/git/ruby/lib/securerandom.rb:94:in `gen_random': can not access instance variables of classes/modules from non-main Ractors (RuntimeError)
	from /Users/aaron/git/ruby/lib/securerandom.rb:155:in `random_bytes'
	from /Users/aaron/git/ruby/lib/securerandom.rb:176:in `hex'
	from ./test.rb:5:in `block (2 levels) in &lt;main&gt;'
	from ./test.rb:4:in `loop'
	from ./test.rb:4:in `block in &lt;main&gt;'
make: *** [runruby] Error
```

After this commit:

```
$ make runruby
./miniruby -I./lib -I. -I.ext/common  ./tool/runruby.rb --extout=.ext  -- --disable-gems ./test.rb
&lt;internal:ractor&gt;:38: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
"3fc8885157e3911bab4b5d7619bb0308"
```
</pre>
</div>
</content>
</entry>
<entry>
<title>fix visibility of SecureRandom.gen_random</title>
<updated>2019-05-14T02:44:20+00:00</updated>
<author>
<name>Urabe, Shyouhei</name>
<email>shyouhei@ruby-lang.org</email>
</author>
<published>2019-05-14T02:44:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=5bab1304af25a843728dbcd2f3594913740aecb0'/>
<id>5bab1304af25a843728dbcd2f3594913740aecb0</id>
<content type='text'>
Aliasing a method preserves its visibility.  These aliases turn
formerly-public methods into private.  Should make them public
again.  [Bug #15847]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Aliasing a method preserves its visibility.  These aliases turn
formerly-public methods into private.  Should make them public
again.  [Bug #15847]
</pre>
</div>
</content>
</entry>
<entry>
<title>lib/securerandom.rb: [DOC] small grammar fixes</title>
<updated>2019-01-20T15:06:11+00:00</updated>
<author>
<name>stomar</name>
<email>stomar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2019-01-20T15:06:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f284eb3d54df6d1bb754986f9f5272136ff73466'/>
<id>f284eb3d54df6d1bb754986f9f5272136ff73466</id>
<content type='text'>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>[DOC] SecureRandom is extended by Random::Formatter.</title>
<updated>2018-12-27T12:42:45+00:00</updated>
<author>
<name>akr</name>
<email>akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2018-12-27T12:42:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b7c2ca7a3225efcc79a72ee3798abc3320f5c304'/>
<id>b7c2ca7a3225efcc79a72ee3798abc3320f5c304</id>
<content type='text'>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>lib/securerandom.rb: improve docs</title>
<updated>2018-06-12T20:22:43+00:00</updated>
<author>
<name>stomar</name>
<email>stomar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2018-06-12T20:22:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=88aaf889231ef1f780ccac49fbf656602264f268'/>
<id>88aaf889231ef1f780ccac49fbf656602264f268</id>
<content type='text'>
* lib/securerandom.rb: [DOC] add alphanumeric example to module docs.
  [Fix GH-1812]

From: Justin Bull &lt;me@justinbull.ca&gt;

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* lib/securerandom.rb: [DOC] add alphanumeric example to module docs.
  [Fix GH-1812]

From: Justin Bull &lt;me@justinbull.ca&gt;

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>lib/securerandom.rb: improve docs</title>
<updated>2018-05-11T20:07:32+00:00</updated>
<author>
<name>stomar</name>
<email>stomar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2018-05-11T20:07:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4b8d33a32345ff16af0df3f14ec439285a3ac6de'/>
<id>4b8d33a32345ff16af0df3f14ec439285a3ac6de</id>
<content type='text'>
* lib/securerandom.rb: [DOC] drop unnecessary `p' from code examples.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* lib/securerandom.rb: [DOC] drop unnecessary `p' from code examples.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>securerandom.rb: [DOC] require in examples</title>
<updated>2018-05-05T03:12:20+00:00</updated>
<author>
<name>nobu</name>
<email>nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2018-05-05T03:12:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=d32763eca0817c92ee0451ee6e08576879317e22'/>
<id>d32763eca0817c92ee0451ee6e08576879317e22</id>
<content type='text'>
* lib/securerandom.rb: added `require 'securerandom'` to each
  example, to state these methods are defined in this library and
  require it explicitly.  [ruby-core:85933] [Bug #14576]

[ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* lib/securerandom.rb: added `require 'securerandom'` to each
  example, to state these methods are defined in this library and
  require it explicitly.  [ruby-core:85933] [Bug #14576]

[ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>securerandom.rb: fix an example of choose [ci skip]</title>
<updated>2017-10-25T07:28:22+00:00</updated>
<author>
<name>nobu</name>
<email>nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2017-10-25T07:28:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7ed3aae2feb91c584c5402dd6f63c145acd1f033'/>
<id>7ed3aae2feb91c584c5402dd6f63c145acd1f033</id>
<content type='text'>
* lib/securerandom.rb (Random::Formatter#choose): [DOC] fix an
  example, `n` is not optional.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* lib/securerandom.rb (Random::Formatter#choose): [DOC] fix an
  example, `n` is not optional.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>less random generations in Random::Formatter#choose.</title>
<updated>2017-10-21T16:12:46+00:00</updated>
<author>
<name>akr</name>
<email>akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2017-10-21T16:12:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=6cba29b4220cc0277f209af9d172f4ec1ddb5f0e'/>
<id>6cba29b4220cc0277f209af9d172f4ec1ddb5f0e</id>
<content type='text'>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>SecureRandom.alphanumeric implemented.</title>
<updated>2017-10-21T15:21:26+00:00</updated>
<author>
<name>akr</name>
<email>akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2017-10-21T15:21:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b867882a1c2a358bb7a46f84365c86a959d35240'/>
<id>b867882a1c2a358bb7a46f84365c86a959d35240</id>
<content type='text'>
[ruby-core:68098] [Feature #10849] proposed by Andrew Butterfield.

SecureRandom.choose and SecureRandom.graph is not included.
(The implementation has SecureRandom.choose but it is private.)

I feel the method name, SecureRandom.choose, doesn't represent
the behavior well.

The actual use cases of SecureRandom.graph is not obvious.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ruby-core:68098] [Feature #10849] proposed by Andrew Butterfield.

SecureRandom.choose and SecureRandom.graph is not included.
(The implementation has SecureRandom.choose but it is private.)

I feel the method name, SecureRandom.choose, doesn't represent
the behavior well.

The actual use cases of SecureRandom.graph is not obvious.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
</feed>
