upstream: https://github.com/mirage/mirage-crypto
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

slack: use Eio.Process for browser, auto-init crypto RNG

- Replace Unix.create_process/waitpid with Eio.Process.run for open_browser
- Add crypto-rng.unix dependency (auto-initializes RNG on load)
- crypto-rng.unix: auto-call use_default() at module init time
- crypto-rng: simplify error message to one actionable line

+13 -16
+9 -16
rng/rng.ml
··· 3 3 exception Unseeded_generator 4 4 exception No_default_generator 5 5 6 - let setup_rng = 7 - "\n\ 8 - Please setup your default random number generator. On Unix, the best path \ 9 - is to call [Crypto_rng_unix.use_default ()].\n\ 10 - But you can use Fortuna (or any other RNG) and setup the seeding (done by \ 11 - default in MirageOS): \n\n\ 12 - To initialize the RNG with a default generator, and set up entropy \ 13 - collection and periodic reseeding as a background task, do the following:\n\ 14 - \ If you are using MirageOS, use the random device in config.ml: `let main \ 15 - = Mirage.main \"Unikernel.Main\" (random @-> job)`, and `let () = register \ 16 - \"my_unikernel\" [main $ default_random]`. \n\ 17 - \ If you are using miou, execute `Crypto_rng_miou_unix.initialize (module \ 18 - Crypto_rng.Fortuna)` at startup." 19 - 20 6 let () = 21 7 Printexc.register_printer (function 22 - | Unseeded_generator -> Some ("The RNG has not been seeded." ^ setup_rng) 8 + | Unseeded_generator -> 9 + Some 10 + "Crypto_rng: generator not seeded. Add crypto-rng.unix to your \ 11 + dependencies (it auto-initializes on load), or call \ 12 + Crypto_rng_unix.use_default () explicitly." 23 13 | No_default_generator -> 24 - Some ("The default generator is not yet initialized. " ^ setup_rng) 14 + Some 15 + "Crypto_rng: no default generator. Add crypto-rng.unix to your \ 16 + dependencies (it auto-initializes on load), or call \ 17 + Crypto_rng_unix.use_default () explicitly." 25 18 | _ -> None) 26 19 27 20 module type Generator = sig
+4
rng/unix/crypto_rng_unix.ml
··· 11 11 set_default_generator g 12 12 13 13 let use_default () = use_getentropy () 14 + 15 + (* Auto-initialize on load so programs that link crypto-rng.unix don't need 16 + an explicit use_default() call. Idempotent: subsequent calls are no-ops. *) 17 + let () = use_default () 14 18 let src = Logs.Src.create "crypto-rng.unix" ~doc:"Mirage crypto RNG Unix" 15 19 16 20 module Log = (val Logs.src_log src : Logs.LOG)