package sodium

  1. Overview
  2. Docs
type hash
type state
type 'a key
type secret_key = secret key
val primitive : string

Primitive used by this implementation. Currently "blake2b".

val wipe_key : secret key -> unit

wipe_key k overwrites k with zeroes.

val size_default : int

Default recommended output size, in bytes.

val size_min : int

Minimum supported output size, in bytes.

val size_max : int

Maximum supported output size, in bytes.

val size_of_hash : hash -> int

size_of_hash hash is the size, in bytes, of the hash hash.

val compare : hash -> hash -> int

compare h h' is 0 if h and h' are equal, a negative integer if h is less than h', and a positive integer if h is greater than h'. compare is not constant time.

val key_size_default : int

Default recommended key size, in bytes.

val key_size_min : int

Minimum supported key size, in bytes.

val key_size_max : int

Maximum supported key size, in bytes.

val size_of_key : secret key -> int

size_of_key key is the size, in bytes, of the key key.

val random_key : unit -> secret key

random_key () generates a random secret key of key_size_default bytes.

derive_key key_size difficulty pw salt derives a key of length key_size from a human generated password. Since the derivation depends on both difficulty and salt, it is necessary to store them alongside the hash. Using a constant salt is insecure because it increases the effectiveness of rainbow tables. Generate the salt with a function like Password_hash.random_salt instead.

val init : ?key:secret key -> ?size:int -> unit -> state

init ?key ?size () is a streaming hash state keyed with key if supplied and computing a hash of size size (default size_default).

val copy : state -> state

copy state is a copy of the state state which can diverge from the original (including finalization).

val final : state -> hash

final state is the final hash of the inputs collected in state.

module type S = sig ... end
module Bytes : S with type storage = Bytes.t
module Bigbytes : S with type storage = bigbytes
OCaml

Innovation. Community. Security.