Skip to content

Commit

Permalink
Merge pull request #222 from hannesm/fix-mirage
Browse files Browse the repository at this point in the history
RNG: fix some docstrings
  • Loading branch information
hannesm authored Mar 27, 2024
2 parents 918bef0 + 116592f commit b1a794a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
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

0 comments on commit b1a794a

Please sign in to comment.