-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getrandom, security and fallback entropy #760
Comments
I think it's the other way around: it should be proven that fallback is needed. And even if such fallback is needed I believe it should be handled on per-target basis, i.e. personally I am not against fallbacks as part of As for |
We might be able to add a target-specific fallback to Therefore I think we should stick to my suggestion and not remove
|
I am not against leaving As for Regarding potential renaming of |
No, you're not understanding me: we shouldn't be telling users to stop using For the most part, |
@cpeterso and @tarcieri, thanks for adding a 👍 to the discussion, but it doesn't help a lot. I am not afraid of bowing to peer pressure, but rational argument and a clear plan is needed. If the plan is to remove Note also that there has not been support for the idea of using secure and insecure "channels" for |
I have not been following your RNG work closely, so I was reluctant to weigh in. :) My opinion is that:
If someone is concerned about an RNG's internal fallback behavior, then they can use the I think hash-map randomization should be infallible by default, but perhaps include a fallible option for users that care. |
There are no secure, universally available infallible options, that much is for sure. The only way of making hash-map randomisation truly infallible is to allow use of a constant key — though arguably it's still better to use a low-entropy key (system clock) and even better to use a high-entropy-but-low-trust key such as from CPU jitter, if secure options are unavailable. Representing so many levels of entropy quality is the part we haven't worked out yet — most of the people here are of the opinion that I have suggested before that we reintroduce |
This thread now seems to be mostly a discussion of entropy security and reliability, so lets make it that.
WIth options 1-2 discounted we should explore the other two options further. There are several potential uses to consider:
I think we can dismiss 2 as a concern — it appears to involve degrading the security of the entire device when necessary to fit a custom usage. If this is deployed on an OS, that OS can be configured to achieve this goal; on embedded devices we already plan to allow custom entropy sources. It does however mean that attempting to periodically improve security (e.g. what To cover these use-cases, possibly two kinds of entropy source are sufficient: secure only, best effort. Then there's It should be noted that hash-map randomisation, probably the thing most needing a fallback, does not use I think this boils down to three questions:
In fact, regardless of these questions, we don't need |
Regarding the need for fallbacks: I would like to highlight that Rust
Why would we do that? Doing so will break "RNG abstraction traits" proposition of the crate. Optional dependency of |
I'm not convinced we need fallbacks. It seems like a very niche use case, given that even What do you think about releasing 0.7 without fallbacks? We could see how many issues occur, and add fallbacks if they are really required. |
Sorry if it wasn't clear; this was actually my conclusion at the end of this morning's post. However, it makes sense to have a plan for handling them in case we do need them (especially since we are discussing the removal of the current mechanism for handling fallbacks).
Doing so doesn't break anything, and if we are already making |
The idea behind |
We should feature-gate this (disabled by default, but enabled automatically in Rand), thus it won't be extra code in libraries only using core functionality, but of course it would be included anyway by most Rand users. |
As you've said yourself some time ago including block stuff into
Considering that |
Interesting point, though it would require some redesign: There are not many other users of |
If
This means we have to commit to |
Note: |
This is a nice way to get rid of
I'm not sure we want that code duplication. On the other hand, it is very little code.
I actually prefer |
It may be somewhat confusing to have two different types withe the absolutely same name and implementation, but if you don't want |
Status:
|
Our getrandom crate is close to initial release, which means we can almost start building on it. This means:
rand_os::OsRng
will become a thin wrapper aroundgetrandom
getrandom::Error
values torand_core::Error
values, or replace the latter completely (suggested in Tracker: Rand 0.7 #715)rand_os
crate will become trivially smallIn #715 we have talked about other possible changes:
getrandom
crate should handle other sources on embedded platformsEntropyRng
is no longer neededrand::FromEntropy::from_entropy
withrand_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 withingetrandom
. This means that for now we should either keepEntropyRng
(even if it is merely a wrapper) or plan to put any needed fallback withinOsRng
.Additionally, it seems clear that we don't want to move the
JitterRng
code intorand_core
, and we cannot makerand_core
depend onrand_jitter
circularly. The same applies to therdrand
crate. Thus the only option for including a fallback withinrand_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
orfrom_entropy
intorand_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:
rand_os
with justOsRng
even though this is essentially an empty crateEntropyRng
torand_os
(@burdges suggestion)rand_os
and go back torand::rngs::OsRng
Proposal: 2: move
EntropyRng
andFromEntropy
torand_os
for now, keeping re-exports inrand
, addrdrand
as a fallback option, and put bothjitter
andrdrand
behind feature flags (disabled by default).The text was updated successfully, but these errors were encountered: