package cryptokit

  1. Overview
  2. Docs

Build a MAC (keyed hash function) from the given block cipher. The block cipher is run in CBC mode, and the MAC value is the final value of the initialization vector. Thus, the hash size of the resulting hash is the block size of the block cipher. The optional argument iv specifies the first initialization vector, with a default of all zeroes. The optional argument pad specifies a padding scheme to be applied to the input data; if not provided, no padding is performed.

Build a MAC (keyed hash function) from the given block ciphers c1, c2 and c3. The input is run through c1 in CBC mode, as described for Cryptokit.Block.mac. The final initialization vector is then super-enciphered by c2, then by c3, to provide the final MAC. This construction results in a MAC that is as nearly as fast as Cryptokit.Block.mac c1, but more resistant against brute-force key search because of the additional final encryption through c2 and c3.

method add_substring : bytes -> int -> int -> unit

add_substring b pos len adds len characters from byte array b, starting at character number pos, to the running hash computation.

method add_string : string -> unit

add_substring b pos len adds len characters from byte array b, starting at character number pos, to the running hash computation.

add_string str adds all characters of string str to the running hash computation.

method add_char : char -> unit

add_string str adds all characters of string str to the running hash computation.

add_char c adds character c to the running hash computation.

method add_byte : int -> unit

add_char c adds character c to the running hash computation.

add_byte b adds the character having code b to the running hash computation. b must be between 0 and 255 inclusive.

method result : string

add_byte b adds the character having code b to the running hash computation. b must be between 0 and 255 inclusive.

Terminate the hash computation and return the hash value for the input data provided via the add_* methods. The hash value is a string of length hash_size characters. After calling result, the hash can no longer accept additional data. Hence, do not call any of the add_* methods after result.

method hash_size : int

Terminate the hash computation and return the hash value for the input data provided via the add_* methods. The hash value is a string of length hash_size characters. After calling result, the hash can no longer accept additional data. Hence, do not call any of the add_* methods after result.

Return the size of hash values produced by this hash function, in bytes.

method wipe : unit

Return the size of hash values produced by this hash function, in bytes.

Erase all internal buffers and data structures of this hash, overwriting them with zeroes. See Cryptokit.transform.wipe.

OCaml

Innovation. Community. Security.