Pasexto.Wrapper behaviour (pasexto v0.1.1)

Copy Markdown View Source

PASERK uses symmetric-key encryption to wrap PASETO keys.

This is the most flexible mode in PASERK, as it offers a way to integrate PASERK with multiple key management solutions.

Summary

Types

The configuration created by the wrapper module used to hold that state required to encrypt and decrypt.

t()

Callbacks

Invoked to decrypt the wrapped data into its original key material.

Invoked to encrypt the key material into an opaque binary blob through wrapping.

Invoked when a wrapper is created to initialise its state.

The prefix for the custom wrapping protocol.

Functions

Creates a wrapper using the given module and options.

Types

config()

@type config() :: term()

The configuration created by the wrapper module used to hold that state required to encrypt and decrypt.

t()

@type t() :: %Pasexto.Wrapper{config: config(), module: module()}

Callbacks

decrypt(config, version, header, wrapped)

@callback decrypt(
  config(),
  Pasexto.Key.version(),
  header :: binary(),
  wrapped :: binary()
) ::
  {:ok, Pasexto.Key.material()} | {:error, term()}

Invoked to decrypt the wrapped data into its original key material.

encrypt(config, version, header, material)

@callback encrypt(
  config(),
  Pasexto.Key.version(),
  header :: binary(),
  material :: Pasexto.Key.material()
) ::
  {:ok, binary()} | {:error, term()}

Invoked to encrypt the key material into an opaque binary blob through wrapping.

init(keyword)

@callback init(keyword()) :: config()

Invoked when a wrapper is created to initialise its state.

prefix()

@callback prefix() :: atom()

The prefix for the custom wrapping protocol.

Functions

new(wrapper, opts)

@spec new(
  module(),
  keyword()
) :: t()

Creates a wrapper using the given module and options.

The options are specific to the wrapper module chosen, and thus their documentation should be referred to for the specifics.