WardrikVault.Sealed (wardrik_vault v0.1.0-rc.1)

Copy Markdown

A credential as the vault writes it. Only a key can unseal it.

Summary

Types

t()

A sealed secret or grant.

Functions

Decodes base64 keys. Drops any that don't hold 32 bytes.

Returns a new key, base64-encoded.

Seals value with key. Binds it to path and kind, so it can't be moved or relabelled.

Unseals with the first of keys that opens it.

Types

t()

@type t() :: %WardrikVault.Sealed{
  ciphertext: binary(),
  kind: :secret | :grant,
  nonce: binary(),
  tag: binary(),
  version: pos_integer()
}

A sealed secret or grant.

Functions

decode_keys(keys)

@spec decode_keys([String.t()]) :: [binary()]

Decodes base64 keys. Drops any that don't hold 32 bytes.

generate_key()

@spec generate_key() :: String.t()

Returns a new key, base64-encoded.

seal(key, path, kind, value)

@spec seal(binary(), String.t(), :secret | :grant, binary()) :: t()

Seals value with key. Binds it to path and kind, so it can't be moved or relabelled.

unseal(sealed, keys, path)

@spec unseal(t(), [binary()], String.t()) :: {:ok, binary()} | {:error, term()}

Unseals with the first of keys that opens it.

Returns {:error, :undecipherable} if none does, and {:error, {:unknown_version, version}} for a version this release can't read.