Closed newpavlov closed 1 week ago
Probably should be rand_thread_rng
How about rand_trng
?
This PR is mostly ready for review. I will work on docs and readme after it's decided that we will move forward with it.
Do we want this?
I do. :) My main motivation is to be able to use and recommend rand
's ThreadRng
for uses in cryptographic applications.
My main motivation is to be able to use and recommend rand's ThreadRng for uses in cryptographic applications.
You can already. And if you're talking about the disclaimer, it applies to this just as much as it does to rand
.
I can not fully recommend it now because it pulls the whole rand
, which is not a small dependency. Everything else except ThreadRng
does not have any uses in this context as was mentioned in #1514.
How about
rand_trng
?
@newpavlov you were the only proponent in #716 while several people were against, and I haven't seen any change there.
@vks @tarcieri WDYT?
Having ThreadRng
in the rand
crate and having it marked as CryptoRng
seems somewhat at odds with #1514.
I guess the actual wording in the changes in #1514 is perhaps not as strong as "rand is not a crypto library":
Rand is not: [...] A cryptography library. Rand provides functionality for generating unpredictable random data (potentially applicable depending on requirements) but does not provide high-level cryptography functionality.
I would argue a CSRNG is high-level cryptographic functionality. It is not uncommon for cryptography libraries to suggest the use of thread_rng
in end user-facing documentation for the purpose of creating cryptographic secrets including keys.
My POV is that #1514 is mostly a disclaimer: rand
is a community project which cannot provide binding guarantees. Meanwhile, rand
has basically always tried to provide a fast and unpredictable randomness source, though IIUC the original motivation had less emphasis on absolute security and more on avoiding a DoS attack through hash keys.
This was previously discussed in #716 and recently raised in #1514.
The main disadvantage of moving thread RNG into its own crates is that users of
rand
(with default crate features) will have one additional dependency in their dependency tree. On the other hand,ThreadRng
can be now used without the rest ofrand
(e.g. in cryptographic applications). It also results in simpler configuration flags and thread RNG code, since we don't need to deal with the generality ofReseedingRng
.If
ReseedingRng
is not used in practice (cursory search on GitHub shows mostly vendoredrand
code), we probably can remove it completely or move into a separate crate.