CRYPTO.Entropy
Entropy gathering (from the OS).
val gather : int -> Bytes.t
gather n
gathers n
bytes of entropy from your operating system. The function blocks until enough entropy is gathered.
The maximal n
that can be used is platform dependent and Sys_error
is raised if the request cannot be satisfied. However, using no more than 256 bytes should be safe.
This does:
getentropy
on Linux, MacOS and other unixes that support it.RtlGenRandom
on Windows (safe to use despite the availability warning).Sys_error
otherwise, notably on NetBSD.Raises Sys_error
in case of problem. If this happen do not try to handle the exception, log it at the toplevel of your program and abort the program. It likely indicates a serious error condition in the system.