From: corey@... Date: 2014-02-26T23:32:08+00:00 Subject: [ruby-core:61112] [ruby-trunk - Feature #9569] SecureRandom should try /dev/urandom first Issue #9569 has been updated by Corey Csuhta. Akira, can you address this point?
SecureRandom in Ruby will use /dev/urandom if OpenSSL is not available, based on the code snippet I linked in the original post. This is contrary to your statement that /dev/urandom is not safe for sessions, or frequent access. As currently implemented, SecureRandom will access /dev/urandom frequently if OpenSSL is not available.---------------------------------------- Feature #9569: SecureRandom should try /dev/urandom first https://bugs.ruby-lang.org/issues/9569#change-45496 * Author: Corey Csuhta * Status: Rejected * Priority: Normal * Assignee: * Category: lib * Target version: current: 2.2.0 ---------------------------------------- Right now, `SecureRandom.random_bytes` tries to detect an OpenSSL to use before it tries to detect `/dev/urandom`. I think it should be the other way around. In both cases, you just need random bytes to unpack, so SecureRandom could skip the middleman (and [second point of failure](http://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers/)) and just talk to `/dev/urandom` directly if it's available. Is this a case of just re-ordering the two code chunks so that `/dev/urandom` is tried first? Relevant lines: https://github.com/ruby/ruby/blob/trunk/lib/securerandom.rb#L59-L90 -- http://bugs.ruby-lang.org/