package mirage-crypto

  1. Overview
  2. Docs
type key
val of_secret : maclen:int -> Cstruct.t -> key

Construct the encryption key corresponding to secret, that will produce authentication codes with the length maclen.

  • raises Invalid_argument

    if the length of secret is not in key_sizes or maclen is not in mac_sizes

val key_sizes : int array

Key sizes allowed with this cipher.

val block_size : int

The size of a single block.

val mac_sizes : int array

MAC lengths allowed with this cipher.

val encrypt : key:key -> nonce:Cstruct.t -> ?adata:Cstruct.t -> Cstruct.t -> Cstruct.t

encrypt ~key ~nonce ?adata msg is msg encrypted under key and nonce, packed with authentication data computed over msg and adata.

  • raises Invalid_argument

    if nonce is not between 7 and 13 bytes long.

val decrypt : key:key -> nonce:Cstruct.t -> ?adata:Cstruct.t -> Cstruct.t -> Cstruct.t option

decrypt ~key ~nonce ?adata msg is Some text when msg was produced by the corresponding encrypt, or None otherwise.

  • raises Invalid_argument

    if nonce is not between 7 and 13 bytes long.

OCaml

Innovation. Community. Security.