From: naruse@... Date: 2020-11-26T08:54:27+00:00 Subject: [ruby-core:101086] [Ruby master Misc#17319] Rename Random.urandom to os_random and document random data sources Issue #17319 has been updated by naruse (Yui NARUSE). zofrex (James Sanderson) wrote in #note-11: > Thank for explaining the rationale behind the naming, I understand it now. > > How would you feel about a patch just to update the documentation, and leave the method names as they are? The documentation still only lists openssl, urandom, and win32 as sources, I think it would be good to list all the potential sources for completeness. You may already read, Random.urandom actually don't use `/dev/urandom` on many OSes. On Linux it uses `getrandom(2)`. On macOS it uses `SecRandomCopyBytes`. On some new BSDs it uses `arc4random_buf`. You can write down this list now. But who updates it when the implementation changes in the future. Improving documentation is good. But we also need to care about maintainability. In the view of maintainability, "completeness" is bad smell. ---------------------------------------- Misc #17319: Rename Random.urandom to os_random and document random data sources https://bugs.ruby-lang.org/issues/17319#change-88763 * Author: zofrex (James Sanderson) * Status: Rejected * Priority: Normal ---------------------------------------- SecureRandom gets randomness from `Random.urandom`, which is a confusing name because `urandom` only uses /dev/urandom in some circumstances. On reading the `secure_random.rb` code this morning I got very confused how it was supporting "win32" for example, because it appears to only use openssl and /dev/urandom. I have renamed `urandom` to `os_random`. With this change, it is much more obvious from reading `secure_random.rb` what is happening, in my opinion. I have also added `urandom` as an alias to `os_random` so this is not a breaking change. I am not 100% sure I documented this alias correctly. I have also updated the documentation for `os_random` (was `urandom`), `SecureRandom`, and `random_raw_seed` to reflect that there are multiple potential sources for random data, not just urandom, openssl, and win32. -- https://bugs.ruby-lang.org/ Unsubscribe: