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

View Source

Behaviour for AEAD cipher functions (spec §4.2).

decrypt/4 returns :error on authentication failure or when the ciphertext is shorter than the 16-byte tag. A default rekey/1 (spec §4.2: ENCRYPT(k, 2^64-1, zerolen, zeros[32])) is provided by use Noise.Crypto.Cipher.

Summary

Functions

Largest nonce value; reserved for rekey/1 (spec §5.1).

Types

key()

@type key() :: <<_::256>>

nonce()

@type nonce() :: 0..18_446_744_073_709_551_615

Callbacks

decrypt(k, n, ad, cipher_text)

@callback decrypt(k :: key(), n :: nonce(), ad :: binary(), cipher_text :: binary()) ::
  (plain_text :: binary()) | :error

encrypt(k, n, ad, plain_text)

@callback encrypt(k :: key(), n :: nonce(), ad :: binary(), plain_text :: binary()) ::
  cipher_text :: binary()

rekey(key)

@callback rekey(key :: key()) :: key()

Functions

max_nonce()

Largest nonce value; reserved for rekey/1 (spec §5.1).