RNG seeding on Lwt/Unix.
This module provides RNG seeding from the Unix kernel RNG, typically
. It uses
Lwt for periodic background reseeding.
Calling initialize is enough to bring the RNG into a working state. In addition, a background task is set up to periodically reseed the RNG.
initialize is idempotent as long as the default generator is unchanged. It is harmless to call it several times.
initialize returns a thread. While the reseeding task has only been created once this thread completes, the initial seeding is done before the function returns. Is is safe to use the RNG immediately after the invocation.
Seed during module initialization, not waiting for the background seeding to start:
let _ = Nocrypto_entropy_lwt.initialize ()
Seed just before the main function, not waiting for the background seeding to start:
let () = ignore (Nocrypto_entropy_lwt.initialize ()); Lwt_main.run (main ())
Seed just before the main function, and wait for the background seeding to start before proceeding:
let () = Lwt_main.run (Nocrypto_entropy_lwt.initialize () >>= main)
val initialize : unit -> unit Lwt.t
attach ~period ~device g instruments the lwt event loop to mix in bytes from
g whenever external events cause the loop to wake up, but no more often than once every
device defaults to