Skip to content
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

RNG: fix some docstrings #222

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mirage/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ let () =
package "mirage-crypto-pk" ;
package "mirage-crypto" ;
package ~min:"0.8.7" "fmt" ;
package "ohex" ;
]
in
register ~packages "crypto-test" [main $ default_random]
8 changes: 4 additions & 4 deletions mirage/unikernel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module Main (R : Mirage_random.S) = struct
Logs.info (fun m -> m "using Fortuna, entropy sources: %a"
Fmt.(list ~sep:(any ", ") Mirage_crypto_rng.Entropy.pp_source)
(Mirage_crypto_rng.Entropy.sources ())) ;
Logs.info (fun m -> m "64 byte random:@ %a" Cstruct.hexdump_pp
Logs.info (fun m -> m "64 byte random:@ %a" (Ohex.pp_hexdump ())
(R.generate 64)) ;
let n = Cstruct.create 32 in
let n = Bytes.(unsafe_to_string (create 32)) in
let key = Mirage_crypto.Chacha20.of_secret n
and nonce = Cstruct.create 12
and nonce = Bytes.(unsafe_to_string (create 12))
in
Logs.info (fun m -> m "Chacha20/Poly1305 of 32*0, key 32*0, nonce 12*0: %a"
Cstruct.hexdump_pp
(Ohex.pp_hexdump ())
(Mirage_crypto.Chacha20.authenticate_encrypt ~key ~nonce n));
let key = Mirage_crypto_pk.Rsa.generate ~bits:4096 () in
let signature =
Expand Down
8 changes: 5 additions & 3 deletions rng/mirage_crypto_rng.mli
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,13 @@ val unset_default_generator : unit -> unit
(**/**)

val generate_into : ?g:g -> bytes -> ?off:int -> int -> unit
(** Invoke {{!Generator.generate}generate} on [g] or
{{!generator}default generator}. The offset [off] defaults to 0. *)
(** [generate_into ~g buf ~off len] invokes
{{!Generator.generate_into}generate_into} on [g] or
{{!generator}default generator}. The random data is put into [buf] starting
at [off] (defaults to 0) with [len] bytes. *)

val generate : ?g:g -> int -> string
(** Invoke {generate_into} on [g] or {{!generator}default generator} and a
(** Invoke {!generate_into} on [g] or {{!generator}default generator} and a
freshly allocated string. *)

val block : g option -> int
Expand Down
Loading