-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tracking issue for stabilizing randomness #27703
Comments
|
Nominating for discussion at libs meeting: we're not ready to stabilize anything here, but I'd like to discuss the plan. |
Unfortunately the libs team didn't get a chance to talk about this in terms of stabilization for 1.8, but I'm going to leave the nominated tag as I think we should chat about this regardless. |
Suggestions:
Obviously, I am biased, but I think a better API for a CSPRNG is the very simple one in ring: https://briansmith.org/rustdoc/ring/rand/index.html. This type of interface is sufficient for every use of a CSPRNG I've ever needed. Note that an implementation of an interface like |
Note that |
More feedback: Currently For some applications, this is unacceptable. The interface should have results returned using However, it is also the case that some implementations may experience errors that they cannot avoid, so it may be worth allowing an implementation to panic or abort the process if it has no other choice on failure. |
That’s |
I'm assuming that the |
Just FYI, I outlined what I think such an API should look like at |
+1 from me on the design of Ideal randomness APIs are infallible, for example OpenBSD's getentropy(2), or Linux's getrandom(2) with a wrapper. It would be nice to have an |
I'm not sure what the current status of this issue is, but tt would be ideal to have at least some portion of |
I agree with @briansmith that Above that, there are as more users who care about the performance of I'd suggest we clearly warn about the side channel vulnerabilities the We should remove functionality from |
wrt constant-time generation, I assume you're talking about a userspace CSPRNG seeded from the kernel? There was some discussion in the recent internals thread about this, and I argued that user-space CSPRNGs are dangerous, and some agreed. The takeaway is that the discussion there seems to be leaning towards a) cryptographically-secure generation by default and, b) not providing user-space PRNGs by default. |
I meant there should be versions that use constant time comparisons in the methods of |
Sorry, my point isn't that being constant-time isn't a good thing (and I know that "constant time" should really be "timing doesn't leak information about the seed"), but rather that this discussion seems to assume a user-land CSPRNG. A user-land CSPRNG is fine, but my point is simply that the default should be to not use a user-land CSPRNG for the reasons outlined in the thread I linked to. It's fine if users want to enable it (presuming we document the security risks), but it shouldn't be the default. |
I see no user-land CSPRNG assumptions here. There is a discussion about There are legitimate needs for short lived user-land CSPRNGs in protocols with deterministic commitments, inside KDFs, etc., but those usages are niche enough that an external crate suffices. |
Common misconception, but it's not true. Properly-seeded CSPRNGs can never run out of entropy.
Probably a misreading on my part. To me, the discussion of constant-time CSPRNGs implied a user-land implementation (constant-timeness isn't a concern when using using kernel-provided randomness - you just get what the kernel gives you, take it or leave it). That's the only reason I was concerned. |
The |
Long ago we had
std::rand
and nowadays we haveextern crate rand
. This is such core functionality it likely wants to move back into the standard library at some point, and in the meantime this issue serves as a tracking issue for therand
feature in the standard library.The process for adding this functionality to the standard library will likely look like something along the lines of rust-lang/rfcs#1242.
cc @huonw
The text was updated successfully, but these errors were encountered: