Expose ThreadRng internal as ThreadRngCore#1750
Expose ThreadRng internal as ThreadRngCore#1750LiosK wants to merge 2 commits intorust-random:masterfrom
Conversation
This commit refactors `ThreadRng` to separate its internal PRNG and reseeding logic as `ThreadRngCore` so the new type could be exposed to public in the future for those who want to copy `ThreadRng` behavior with an independent state or in a Send + Sync context. See also rust-random#1748
|
Design question: there would be two ways to expose the ThreadRng internal:
This PR chose the former because it is simpler, clearer, and focused on the needs to copy |
|
Personally, I don't think we should do this. IIUC your main motivation is aws/s2n-quic#2986, I left an alternative suggestion in the comment there. Also, if your goal is to make the type public, it should be done as part of this PR. |
|
Hi, I am not from aws/s2n-quic. I just found it relevant but should have opened a new issue. The motivation behind this is to provide users with ability to reuse With a more convenient type, more users might be interested in reusing |
|
As I wrote in the original issue, we could re-introduce Moreover, I consider reliance on reseeding RNG to be an anti-pattern more often than not (i.e. users should use either a "stateless" RNG like |
|
Reseeding RNGs give you forward secrecy over ones which use a persistent seed/key |
|
Sure, but if you want forward secrecy then it's better to select a CSPRNG which provides it out of the box instead of relying on the reseeding hack. |
|
Reseeding is controversial, and AFAIK it's just a nice-to-have feature, but because it's nice to have, Also, I am fully convinced that |
|
Why call this Relative to
The complexity that this does have is that there is another piece of API which must be specified. You haven't made this pub or written docs for it which are arguably the most important part of such an addition. So, why should people use this? The reason |
I don't think it's a sufficient motivation for this addition. As I wrote in the Ideally, |
|
Thank you very much for your inputs. I added minimum viable doc to
The answer is likely to be the same as the reason why
|
This commit refactors
ThreadRngto separate its internal PRNG and reseeding logic asThreadRngCoreso the new type could be exposed to public in the future for those who want to copyThreadRngbehavior with an independent state or in a Send + Sync context.See also #1748