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
mirage-crypto-rng-async #90
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR.
I have not used async (yet) - this looks like a good addition. I'd be happy to merge this PR (apart from the question about blocking behaviour of getrandom
).
If that code is reached then the random source has been initialized it will never block.
So a few things to deal with: the win32 build is broken and, reading |
mirage-crypto/.github/workflows/test.yml Line 33 in de52120
|
Took me a while to figure out what the issue is. Turns out, the windows runner uses a different opam-repository (https://github.com/fdopen/opam-repository-mingw/) - where async is marked as unavailable on windows. To have the CI succeed, I guess all that is needed is to specify
That looks good. There is For lwt (and async), it would be good to have tests which validate "that initialization was unique across runs and timers were being scheduled properly" (but I haven't bothered developing such a test so far). Your gist looks good, it may be worth to put it in the |
…oid failures on win32)
…nc doesn't add any depext anyways
avoid installation and testing of mirage-crypto-rng-async on windows
Synchronous_time_source.run_at_intervals | ||
time_source | ||
span | ||
(fun () -> Entropy.cpu_rng None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a RaspberryPI 2, this doesn't collect any entropy. Somewhat orthogonal to this PR, but it might be nice to expose something like val Entropy.cpu_native_support : bool
so that implementations can check if it's worthwhile creating the timer.
I updated the interface to make it easier to write the entropy collection test. Assuming CI passes, I think this is good to go? Though, see my note about cpu native entropy sources inline. |
thanks spiros, I squash-merged this to master :) |
…age-crypto-rng-mirage and mirage-crypto-rng-async (0.8.8) CHANGES: - new package mirage-crypto-rng-async, entropy feeding using async (mirage/mirage-crypto#90 @seliopou) - Entropy.cpu_rng and Entropy.cpu_rng_bootstrap result in Error `Not_supported on CPUs without RDRAND/RDSEED support (previously an exception was raised in cpu_rng_bootstrap, and cpu_rng resulted in a no-op) (mirage/mirage-crypto#92 @seliopou) - Entropy.cpu_rng delays entropy feeding (returns unit -> unit instead of unit). This fixes a memory leak, reported by @talex5 mirage/mirage-crypto#94, fixed in mirage/mirage-crypto#95 by @hannesm - Avoid illegal instructions on X86 CPUs without SSSE3 instruction set. Both SHA256 and ChaCha used PSHUFB which is not available on e.g. AMD Phenom II (report mirage/mirage-crypto#93 by @dinosaure @samoht @pirbo @RichAyotte @sebeec, fixed in mirage/mirage-crypto#96 by @hannesm)
This is an implementation of the async-analogue of
Mirage_crypto_rng_lwt
. It's exposes a singleinitialize
function that schedules several periodic jobs to collect entropy from the system and feed it into theEntropy
module for use by the PRNGs.I haven't tested this yet, but wanted to throw this up here to gauge whether this would be a welcome contribution. If this looks good, I will follow it up with getting @dinosaure's async ocaml-tls implementation into a state where it can be merged into that project as well.