forked from mirage/mirage-crypto
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmirage_crypto_rng_unix.mli
35 lines (27 loc) · 1.47 KB
/
mirage_crypto_rng_unix.mli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(** {b RNG} seeding on {b Unix}.
This module initializes a Fortuna RNG with [getrandom()], and CPU RNG.
On BSD systems (FreeBSD, OpenBSD, macOS) [getentropy ()] is used instead
of [getrandom ()]. On Windows 10 or higher, [BCryptGenRandom()] is used
with the default RNG. Windows 8 or lower are not supported by this library.
*)
(** [initialize ~g rng] will bring the RNG into a working state. *)
val initialize : ?g:'a -> 'a Mirage_crypto_rng.generator -> unit
(** [getrandom size] returns a buffer of [size] filled with random bytes. *)
val getrandom : int -> string
(** A generator that opens /dev/urandom and reads from that file descriptor
data whenever random data is needed. The file descriptor is closed in
[at_exit]. *)
module Urandom : Mirage_crypto_rng.Generator
(** A generator using [getrandom(3)] on Linux, [getentropy(3)] on BSD and macOS,
and [BCryptGenRandom()] on Windows. *)
module Getentropy : Mirage_crypto_rng.Generator
(** [use_default ()] initializes the RNG [Mirage_crypto_rng.default_generator]
with [Urandom] or resorts to [Getentropy] if the urandom failed to open the
/dev/urandom device. *)
val use_default : unit -> unit
(** [use_dev_random ()] initializes the RNG [Mirage_crypto_rng.default_generator]
with the [Urandom] generator. *)
val use_dev_urandom : unit -> unit
(** [use_getentropy ()] initializes the RNG [Mirage_crypto_rng.default_generator]
with the [Getentropy] generator. *)
val use_getentropy : unit -> unit