PBCS.ContentEncryptor behaviour (pbcs v0.1.2) View Source

Callback module for content encryptors.

Implement this behaviour if you want to implement your own content encryptor.

Link to this section Summary

Link to this section Types

Specs

t() :: %PBCS.ContentEncryptor{module: module(), params: any()}

Link to this section Functions

Link to this function

decrypt(content_encryptor, key, iv, arg)

View Source

Specs

decrypt(t(), binary(), binary(), {binary(), PBCS.cipher_text(), binary()}) ::
  {:ok, PBCS.plain_text()} | :error
Link to this function

encrypt(content_encryptor, key, iv, arg)

View Source

Specs

encrypt(t(), binary(), binary(), {binary(), PBCS.plain_text()}) ::
  {binary(), PBCS.cipher_text()}
Link to this function

generate_iv(content_encryptor)

View Source

Specs

generate_iv(t()) :: binary()
Link to this function

generate_key(content_encryptor)

View Source

Specs

generate_key(t()) :: binary()
Link to this function

key_length(content_encryptor)

View Source

Specs

key_length(t()) :: pos_integer()

Link to this section Callbacks

Link to this callback

decrypt(params, key, iv, {})

View Source

Specs

decrypt(
  params :: any(),
  key :: binary(),
  iv :: binary(),
  {aad :: binary(), cipher_text :: binary(), cipher_tag :: binary()}
) :: {:ok, binary()} | :error
Link to this callback

encrypt(params, key, iv, {})

View Source

Specs

encrypt(
  params :: any(),
  key :: binary(),
  iv :: binary(),
  {aad :: binary(), plain_text :: binary()}
) :: {binary(), binary()}

Specs

generate_iv(params :: any()) :: binary()

Specs

generate_key(params :: any()) :: binary()

Specs

init(protected :: map(), opts :: Keyword.t()) ::
  {:ok, any()} | {:error, String.t()}

Specs

key_length(params :: any()) :: non_neg_integer()