# `Pasexto.Wrapper`
[🔗](https://github.com/alexkornitzer/pasexto/blob/v0.1.2/lib/pasexto/wrapper.ex#L1)

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.

# `config`

```elixir
@type config() :: term()
```

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

# `t`

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

# `decrypt`

```elixir
@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`

```elixir
@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`

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

Invoked when a wrapper is created to initialise its state.

# `prefix`

```elixir
@callback prefix() :: atom()
```

The prefix for the custom wrapping protocol.

# `new`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
