package mirage-crypto

  1. Overview
  2. Docs
include AEAD
type key

The abstract type for the key.

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

authenticate_encrypt ~key ~nonce ~adata msg encrypts msg with key and nonce, and appends an authentication tag computed over the encrypted msg, using key, nonce, and adata.

  • raises Invalid_argument

    if nonce is not of the right size.

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

authenticate_decrypt ~key ~nonce ~adata msg splits msg into encrypted data and authentication tag, computes the authentication tag using key, nonce, and adata, and decrypts the encrypted data. If the authentication tags match, the decrypted data is returned.

  • raises Invalid_argument

    if nonce is not of the right size.

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.