Noise.Crypto.Hash behaviour (Noise Protocol v0.3.0)

View Source

Behaviour for hash functions (spec §4.3).

Implementations provide hashlen/0, hash/1 and hmac_hash/2; hkdf/3 (spec §4.3) is derived from hmac_hash/2 by use Noise.Crypto.Hash.

Summary

Types

hash()

@type hash() :: <<_::256>> | <<_::512>>

Callbacks

hash(data)

@callback hash(data :: iodata()) :: hash()

hashlen()

@callback hashlen() :: 32 | 64

hkdf(chaining_key, input_key_material, num_outputs)

@callback hkdf(
  chaining_key :: hash(),
  input_key_material :: binary(),
  num_outputs :: 2 | 3
) ::
  {output1 :: hash(), output2 :: hash()}
  | {output1 :: hash(), output2 :: hash(), output3 :: hash()}

hmac_hash(key, data)

@callback hmac_hash(key :: hash(), data :: iodata()) :: hash()