-
Notifications
You must be signed in to change notification settings - Fork 186
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
It should be possible to use a custom implementation when RDRAND is available #230
Comments
The thing that's special about SGX isn't the Also, the only thing special about SGX is that we have to know that we cannot invoke CPUID. It doesn't matter though because it already has IMO, most With this in mind, I don't think we need to have RDRAND (or the ESPIDF equivalent) by default for ANY target. I think instead we could require all these targets to register a custom implementation. Somebody could make a In other words, |
Copying from #438
|
Currently, Perhaps we should create a new custom feature, "custom2", with a better API, and with "overrides features=custom,rdrand" semantics. Then we can issue a deprecated warning when Similarly, when rdrand and custom2 are both enabled at the same time, we should warn that the rdrand feature is deprecated and that the custom2 implementation will be used.
Worst-case scenerio, they can use the RDRAND crate or do it themselves using intrinsics or inline assembly. I do think it is a good idea to support an API for RDRAND, but we should design it separately. Eventually, maybe a year or two from now, when either the original custom or rdrand features are used, we should warn that they are deprecated. |
See
getrandom/src/lib.rs
Lines 208 to 217 in 30308ae
Presently, the RDRAND implementation supersedes the custom implementation, and there's no way to prevent that for SGX or when the
rdrand
feature is explicitly set. Further, there's no way to use RDRAND through this crate from a custom implementation.More generally, in any target we should be able to avoid using RDRAND output directly. For example, in an SGX and/or UEFI or operating system kernel, one may want to implement their own RNG, perhaps one that conforms to external security standards (FIPS, NIST, etc.), perhaps using RDRAND as one entropy source. Or, the implementation may want to mix the RDRAND output into a DRBG (using NIST terminology) to protect against unknown issues with RDRAND.
And, I think we
getrandom
even avoid defaulting to RDRAND on any target.In UEFI and SGX, I would like to force the use of my custom implementation, and I'd like to implement mine partially in terms of RDRAND.
Concretely, I suggest:
rdrand
feature is requested, expose a new API to get the (raw, unbiased) results of RDRAND, independent of the currentgetrandom()
API.rdrand
andcustom
features are requested, provide an API for registering the RDRAND implementation as the custom implementation, and document that environments such as UEFI and SGX must do this registration before usinggetrandom
, just like any custom implementation.The text was updated successfully, but these errors were encountered: