-
-
Notifications
You must be signed in to change notification settings - Fork 486
Description
Our getrandom crate is close to initial release, which means we can almost start building on it. This means:
rand_os::OsRngwill become a thin wrapper aroundgetrandom- either we have to map
getrandom::Errorvalues torand_core::Errorvalues, or replace the latter completely (suggested in Tracker: Rand 0.7 #715) - the
rand_oscrate will become trivially small
In #715 we have talked about other possible changes:
- the
getrandomcrate should handle other sources on embedded platforms - we no longer appear to need a fallback in case of OS failure
- therefore
EntropyRngis no longer needed - we could replace
rand::FromEntropy::from_entropywithrand_core::SeedableRng::from_entropy
Here I would like to add a caveat: we have no proof that a fallback entropy source is not needed. @tarcieri has pointed out in #699 that we cannot be confident of the security of JitterRng, however there is also resistance to merely switching to RDRAND (partly since it is not available on all platforms, and in part based on the belief that we shouldn't need any fallback).
What we do not want to do is remove EntropyRng only to find that we need to add it back again, meanwhile there is strong resistance to the idea of including a fallback within getrandom. This means that for now we should either keep EntropyRng (even if it is merely a wrapper) or plan to put any needed fallback within OsRng.
Additionally, it seems clear that we don't want to move the JitterRng code into rand_core, and we cannot make rand_core depend on rand_jitter circularly. The same applies to the rdrand crate. Thus the only option for including a fallback within rand_core would be a direct RDRAND implementation, which we probably also don't want.
Like it or not, this means that we cannot move OsRng or from_entropy into rand_core unless we can prove that we don't need a fallback.
Now, if we want to pursue a no-fallback entropy source, we could try removing all fallbacks for Rand 0.7 and watch for error reports. However, I'm not sure whether we want to do so (personally I agree with @cpeterso that Rand should "just work").
This means we have to look at other options for now:
- Keep
rand_oswith justOsRngeven though this is essentially an empty crate - Move
EntropyRngtorand_os(@burdges suggestion) - Drop
rand_osand go back torand::rngs::OsRng
Proposal: 2: move EntropyRng and FromEntropy to rand_os for now, keeping re-exports in rand, add rdrand as a fallback option, and put both jitter and rdrand behind feature flags (disabled by default).