-
Notifications
You must be signed in to change notification settings - Fork 182
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
Feature for using CPU-based RNG #84
Comments
I am not sure about this. I think it falls under using a custom Do you suggest using a user-space CSPRNG? What do you plan to use for the initial seed? Either way,
I think if you want performance you should use |
So this is totally possible, but it requires a patch to the That's why I think a feature might make more sense.
Oh I agree,
Correct, |
As I see it we would have a I guess we can add this feature until we get this hypothetical lang item. Can you prepare a PR? |
I guess this makes sense. Then users can use something like following: getrandom = { version = "0.1", package = "getrandom-rdrand" } I don't see how this has anything to do with lang items, and I'm less keen on using feature flags (because it makes it too easy to replace a trusted entropy source with another, potentially less trusted one — the AMD CPU bugs have shown that trusting RDRAND is not always a good idea). |
I think if we are to introduce such feature it should be at the very end of our @josephlr |
@newpavlov all of that sounds very reasonable. It also might be a good idea to use a similar mechanism for both custom randomness and CPU randomness. I can put something together and see how it looks. |
Review of deployment methods
Ignoring the "lang item", Use via
This is essentially
Feature-flags have the same usage implications as custom implementations via #109, but keep code and dependencies within the same crate. If we need RDRAND code within the Actually, there is one additional possibility: providing another level of fallback for sources (OS if available, otherwise RDRAND if enabled and functional, otherwise custom backend). Summary: #109 is not necessarily better than a feature flag for this use-case. |
Agreed, this is essentially the worst option as it puts much more burden on users who have
After trying multiple options locally, I think an extension of the fallback mechanism is the best bet. My idea would be for
This fallback ordering means that a custom backend can always be used, but that we can also provide a sane fallback for x86 targets without having to deal with additional custom backends. I think using Other benefits:
@dhardy @newpavlov What do you think? I'll revise #133 to incorporate this plan. |
Sounds good to me. |
Sounds good to me as well! |
Closed via #133 |
For some custom x86 targets I am working on (https://github.com/intel/rust-hypervisor-firmware), it would be nice to have a feature that says "just use the on-CPU RNG".
Having a feature for this seems better than adding more targets to the list of targets that use RDRAND. It would also be useful more conventional targets (i.e. Linux) that don't want to use a syscall to get random data (i.e. for performance).
The text was updated successfully, but these errors were encountered: