Skip to content

Commit b8f985a

Browse files
committed
Second try at OsRng documentation
1 parent 70c57bf commit b8f985a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/os.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,17 @@ use rand_core::{RngCore, Error, impls};
1919
/// most applications. Commonly it is used to initialize a user-space RNG, which
2020
/// can then be used with much lower overhead.
2121
///
22-
/// Sometimes there is the misconception that `OsRng` somehow provides 'better'
23-
/// random numbers than some good user-space cryptographic random number
24-
/// generator. This is not true, but `OsRng` has a role in initializing such an
25-
/// RNG. The initial seed of randomness has to come from somewhere.
22+
/// Generally you can say that the values generated by `OsRng` are not in some
23+
/// way 'better' than those generated by a good user-space cryptographic random
24+
/// number generator. It is not necessary to use `OsRng` if your only
25+
/// requirements are 'good' random numbers.
26+
///
27+
/// Where `OsRng` especially has a role is in seeding user-space RNGs. The
28+
/// initial seed of randomness has to come from somewhere. And it can also be a
29+
/// good choice if you need a small number of secure random values. We can
30+
/// expect the RNG of the operating system to have mitigations in place for
31+
/// vulnerabilities such as side-channel attacks. But in general it is best rely
32+
/// on security-oriented libraries in such cases, such as OpenSSL or Ring.
2633
///
2734
/// You may prefer to use [`EntropyRng`] instead of `OsRng`. Is is unlikely, but
2835
/// not entirely theoretical, for `OsRng` to fail. In such cases `EntropyRng`

0 commit comments

Comments
 (0)