Skip to content

Commit 344395d

Browse files
committed
Second try at OsRng documentation
1 parent 544f514 commit 344395d

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
@@ -24,10 +24,17 @@ use rand_core::{RngCore, Error, ErrorKind, impls};
2424
/// most applications. Commonly it is used to initialize a user-space RNG, which
2525
/// can then be used with much lower overhead.
2626
///
27-
/// Sometimes there is the misconception that `OsRng` somehow provides 'better'
28-
/// random numbers than some good user-space cryptographic random number
29-
/// generator. This is not true, but `OsRng` has a role in initializing such an
30-
/// RNG. The initial seed of randomness has to come from somewhere.
27+
/// Generally you can say that the values generated by `OsRng` are not in some
28+
/// way 'better' than those generated by a good user-space cryptographic random
29+
/// number generator. It is not necessary to use `OsRng` if your only
30+
/// requirements are 'good' random numbers.
31+
///
32+
/// Where `OsRng` especially has a role is in seeding user-space RNGs. The
33+
/// initial seed of randomness has to come from somewhere. And it can also be a
34+
/// good choice if you need a small number of secure random values. We can
35+
/// expect the RNG of the operating system to have mitigations in place for
36+
/// vulnerabilities such as side-channel attacks. But in general it is best rely
37+
/// on security-oriented libraries in such cases, such as OpenSSL or Ring.
3138
///
3239
/// You may prefer to use [`EntropyRng`] instead of `OsRng`. Is is unlikely, but
3340
/// not entirely theoretical, for `OsRng` to fail. In such cases `EntropyRng`

0 commit comments

Comments
 (0)