Module Digestif.BLAKE2BSource

Sourceval digest_size : int

Size of hash results, in bytes.

Sourcetype ctx
Sourcetype kind = [
  1. | `BLAKE2B
]
Sourcetype t = private string
Sourceval empty : ctx

An empty hash context.

Sourceval init : unit -> ctx

Create a new hash state.

Sourceval feed_bytes : ctx -> ?off:int -> ?len:int -> Bytes.t -> ctx

feed_bytes msg t adds informations in msg to t. feed is analogous to appending: feed (feed t msg1) msg2 = feed t (append msg1 msg2)

Sourceval feed_string : ctx -> ?off:int -> ?len:int -> String.t -> ctx

Same as feed_bytes but for String.t.

Sourceval feed_bigstring : ctx -> ?off:int -> ?len:int -> bigstring -> ctx

Same as feed_bytes but for bigstring.

Sourceval feedi_bytes : ctx -> Bytes.t iter -> ctx

feedi_bytes t iter = let r = ref t in iter (fun msg -> r := feed !r msg); !r

Sourceval feedi_string : ctx -> String.t iter -> ctx

Same as feed_bytes but for String.t.

Sourceval feedi_bigstring : ctx -> bigstring iter -> ctx

Same as feed_bytes but for bigstring.

Sourceval get : ctx -> t

get t is the digest corresponding to t.

Sourceval digest_bytes : ?off:int -> ?len:int -> Bytes.t -> t

digest_bytes msg is the digest of msg.

digest_bytes msg = get (feed_bytes empty msg).

Sourceval digest_string : ?off:int -> ?len:int -> String.t -> t

Same as digest_bytes but for a String.t.

Sourceval digest_bigstring : ?off:int -> ?len:int -> bigstring -> t

Same as digest_bytes but for a bigstring.

Sourceval digesti_bytes : Bytes.t iter -> t

digesti_bytes iter = feedi_bytes empty iter |> get.

Sourceval digesti_string : String.t iter -> t

Same as digesti_bytes but for String.t.

Sourceval digesti_bigstring : bigstring iter -> t

Same as digesti_bigstring but for bigstring.

Sourceval digestv_bytes : Bytes.t list -> t

Specialization of digesti_bytes with a list of Bytes.t (see iter).

Sourceval digestv_string : String.t list -> t

Same as digestv_bytes but for String.t.

Sourceval digestv_bigstring : bigstring list -> t

Same as digestv_bytes but for bigstring.

Sourceval hmac_bytes : key:Bytes.t -> ?off:int -> ?len:int -> Bytes.t -> t

hmac_bytes ~key bytes is the authentication code for Bytes.t under the secret key, generated using the standard HMAC construction over this hash algorithm.

Sourceval hmac_string : key:String.t -> ?off:int -> ?len:int -> String.t -> t

Same as hmac_bytes but for String.t.

Sourceval hmac_bigstring : key:bigstring -> ?off:int -> ?len:int -> bigstring -> t

Same as hmac_bytes but for bigstring.

Sourceval hmaci_bytes : key:Bytes.t -> Bytes.t iter -> t

Authentication code under the secret key over a collection of Bytes.t.

Sourceval hmaci_string : key:String.t -> String.t iter -> t

Same as hmaci_bytes but for String.t.

Sourceval hmaci_bigstring : key:bigstring -> bigstring iter -> t

Same as hmaci_bytes but for bigstring.

Sourceval hmacv_bytes : key:Bytes.t -> Bytes.t list -> t

Specialization of hmaci_bytes with a list of Bytes.t (see iter).

Sourceval hmacv_string : key:String.t -> String.t list -> t

Same as hmacv_bytes but for String.t.

Sourceval hmacv_bigstring : key:bigstring -> bigstring list -> t

Same as hmacv_bigstring but for bigstring.

Sourceval unsafe_compare : t compare

unsafe_compare function returns 0 on equality and a negative/positive int depending on the difference (like String.compare). However, this behavior is dangerous since sorting by these hashes can allow attackers to infer information about them.

Sourceval compare : t compare

compare a b uses caml_hash (murmur3) to get an unique integer of a and b a do a substraction on them. Order is not lexicographical. The safety relies on the assumption that the murmur3 seed cannot be reconstructed by an attacker.

About safety, t is private string and let the user to define its own compare function.

Sourceval eq : t equal

The equal function for t.

Sourceval neq : t equal

neq a b = not (eq a b).

Sourceval pp : t pp

Pretty-printer of t.

Sourceval of_hex : string -> t

of_hex tries to parse an hexadecimal representation of t. of_hex raises an invalid_argument when input is malformed. We take only firsts digest_size hexadecimal values and ignore rest of input. If it has not enough hexadecimal values, trailing values of the output hash are zero (\x00),

Sourceval consistent_of_hex : string -> t

consistent_of_hex tries to parse an hexadecimal representation of t. consistent_of_hex raises an invalid_argument when input is malformed. However, instead of_hex, consistent_of_hex expects exactly digest_size hexadecimal values (but continues to ignore whitespaces).

Sourceval to_hex : t -> string

to_hex makes a hex-decimal representation of t.