package mirage-crypto

  1. Overview
  2. Docs
type key
val of_secret : string -> key

Construct the encryption key corresponding to secret.

  • raises Invalid_argument

    if the length of secret is not in key_sizes.

val key_sizes : int array

Key sizes allowed with this cipher.

val block_size : int

The size of a single block.

val encrypt : key:key -> string -> string

encrypt ~key src encrypts src into a freshly allocated buffer of the same size using key.

  • raises Invalid_argument

    if the length of src is not a multiple of block_size.

val decrypt : key:key -> string -> string

decrypt ~key src decrypts src into a freshly allocated buffer of the same size using key.

  • raises Invalid_argument

    if the length of src is not a multiple of block_size.

val encrypt_into : key:key -> string -> src_off:int -> bytes -> dst_off:int -> int -> unit

encrypt_into ~key src ~src_off dst dst_off len encrypts len octets from src starting at src_off into dst starting at dst_off.

  • raises Invalid_argument

    if len is not a multiple of block_size.

  • raises Invalid_argument

    if src_off < 0 || String.length src - src_off < len.

  • raises Invalid_argument

    if dst_off < 0 || Bytes.length dst - dst_off < len.

val decrypt_into : key:key -> string -> src_off:int -> bytes -> dst_off:int -> int -> unit

decrypt_into ~key src ~src_off dst dst_off len decrypts len octets from src starting at src_off into dst starting at dst_off.

  • raises Invalid_argument

    if len is not a multiple of block_size.

  • raises Invalid_argument

    if src_off < 0 || String.length src - src_off < len.

  • raises Invalid_argument

    if dst_off < 0 || Bytes.length dst - dst_off < len.

OCaml

Innovation. Community. Security.