package mirage-crypto

  1. Overview
  2. Docs
Simple symmetric cryptography for the modern age

Install

dune-project
 Dependency

Authors

Maintainers

Sources

mirage-crypto-0.11.3.tbz
sha256=bfb530fa169cd905ebc7e2449f3407cfbd67023ac0b291b8b6f4a1437a5d95b1
sha512=7b6f4e8128622b53eb2176881b5d6160f224e8606c7dd21aaf47974f15db7aa475cffaff3214aaaabba0f8986398f159c1fbb1bff29228c9b0a3fae67ef8d731

doc/mirage-crypto/Mirage_crypto/Hash/index.html

Module Mirage_crypto.HashSource

Hashes.

Each algorithm is contained in its own module, with high-level operations accessible through functions that dispatch on code value.

type digest = Cstruct.t
type 'a iter = ('a -> unit) -> unit

A general (inner) iterator. It applies the provided function to a collection of elements.

For instance:

  • let iter_k : 'a -> 'a iter = fun x f -> f x
  • let iter_pair : 'a * 'a -> 'a iter = fun (x, y) f = f x; f y
  • let iter_list : 'a list -> 'a iter = fun xs f -> List.iter f xs

Hashing algorithms

module type S = sig ... end

A single hash algorithm.

module MD5 : S
module SHA1 : S
module SHA224 : S
module SHA256 : S
module SHA384 : S
module SHA512 : S

Codes-based interface

type hash = [
  1. | `MD5
  2. | `SHA1
  3. | `SHA224
  4. | `SHA256
  5. | `SHA384
  6. | `SHA512
]

Algorithm codes.

val hashes : hash list

hashes is a list of all implemented hash algorithms.

val module_of : [< hash ] -> (module S)

module_of hash is the (first-class) module corresponding to the code hash.

This is the most convenient way to go from a code to a module.

Hash functions

val digest : [< hash ] -> Cstruct.t -> digest

digest algorithm bytes is algorithm applied to bytes.

val digesti : [< hash ] -> Cstruct.t iter -> digest

digesti algorithm iter is algorithm applied to iter.

val mac : [< hash ] -> key:Cstruct.t -> Cstruct.t -> digest

mac algorithm ~key bytes is the mac algorithm applied to bytes under key.

val maci : [< hash ] -> key:Cstruct.t -> Cstruct.t iter -> digest

maci algorithm ~key iter is the mac algorithm applied to iter under key.

val digest_size : [< hash ] -> int

digest_size algorithm is the size of the algorithm in bytes.