Keys are used to build and parse tokens, which are always scoped to a specific PASETO version and purpose.
A Key can be created like so:
iex> key = Pasexto.Key.new(:v4, :local)If the key material has been created elsewhere it can be provided to
Pasexto.Key.new/3:
iex> material = <<201, 3, 44, 87, 98, 136, 53, 5, 211, 173, 138, 220, 3, 167, 157,
215, 185, 137, 185, 48, 48, 162, 235, 83, 44, 168, 166, 118, 59, 241, 154,
117>>
iex> key = Pasexto.Key.new(:v4, :local, material)
Summary
Functions
Extracts the key material for a given protocol version and purpose.
Returns key matrial from the provided PEM.
Returns a key for use with the given protocol version and purpose.
Types
@type material() :: term()
The key material.
@type purpose() :: :local | :public
The protocol purpose for the key.
@type version() :: :v1 | :v2 | :v3 | :v4
The protocol version for the key.
Functions
@spec extract(t(), version(), purpose()) :: {:ok, material()} | {:error, :invalid_purpose | :invalid_version}
Extracts the key material for a given protocol version and purpose.
Returns an error if the version or purpose do not match that of the key.
Returns key matrial from the provided PEM.
Options
password- The password for use with encrypted PEMs.
Raises an argument error if the PEM does not contain material that is valid for PASETO protocols.
Returns a key for use with the given protocol version and purpose.
If the key material is not provided then new material will be made for the selected protocol.
Raises an argument error if invalid key material is provided for a given protocol.