-
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
Split OS RNG into rand_os #643
Conversation
I wasn't expecting this. Is this your take on the discussion in #290? Because it's not what I had in mind. Splitting that big |
Nah, I always wanted to move OS RNG into a separate crate (and I am a bit surprised you don't want to), as it does not make much sense to depend on the whole I think that entropy and thread RNGs can be implemented on the top of |
@aturon do you see this fitting into the We already have implementations for some platforms you don't; it should make it easier porting Rust to new languages if this stuff only has to be written once. |
I'm probably not the best person to ask (I'm not involved with |
I think providing a direct interface to the OS's secure random facility is a reasonable primitive to provide in the standard library personally. As you mentioned, we already rely on it for hashmap keying, and the interface of |
@sfackler It could be done using mutable statics, but it's not the best solution. |
Sure, it could be backed by a weak lang item potentially, though that's starting to go further down the API design rabbit hole. |
@sfackler a "simple" function like Our current interface is a bit more nuanced with detection for initialisation as well as potential errors on use. I think we should at least have reporting for "not ready yet" and "other error" through error codes. As @newpavlov says, we should try to make something usable with There's an additional complication: As you say, it is an API design rabbit-hole which for sure needs an RFC to implement, but I think it would be worth trying to unify our OS random interfaces. Also in #579 we discussed using lang items to solve Unfortunately, there is yet another complication. We use |
As @newpavlov says in #648 it's probably worth moving forward with this anyway. So I'd like to review (or at least have one independent review) but don't have a lot of time for that myself now. Maybe @tarcieri would like to review? |
Not sure how to fix errors with doc upload and |
Some doc links are broken; you'll have to search for them:
Not sure about the other one. I tried restarting it, but I don't expect it to go away... |
@alexcrichton any idea why this WASM build fails? CI log |
BTW how about moving most of the |
Sure, go for it. Another option is moving docs to the book, though I'm not sure if it's appropriate in this case. |
Okay, have it your way and just re-export Then I think the only blocker is the WASM test. I don't have any ideas and don't really have the time to investigate. |
@ashleygwilliams |
Sorry @newpavlov; I restarted the test runner but it appears it's still based on pre- #660 code. Can you rebase? |
One thing that occurs to me is that if we get an OS-RNG interface in lib core, then we can make I guess it's time to try writing that RFC we talked about in #648 ... |
I don't think so, I've stated my opinion regarding it here. |
@newpavlov could you please rebase on latest master? |
Done! |
Well, I've "fixed" the CI issue, one of the reasons behind it was koute/cargo-web#72, though |
Thanks @newpavlov; I guess that will do. I made a few tweaks in my branch; could you pull them please: https://github.com/dhardy/rand/tree/rand_os |
rand_os: doc and cargo improvements
Done. |
This PR moves OS RNG into the separate crate with some code reorganization. Changes should be double checked, as I've only tested them for Linux.