SaltDns.Vault (Salt v1.0.0)

Encryption at rest for secrets (TSIG secrets, TOTP secrets, DNSSEC key material), built on SaltDns.Crypto (AES-256-GCM). Ported from Karta.Vault (MIT, Shiloh B.V.).

Configuration (application environment of :salt_dns):

  • :vault_key (required): the active key, base64 of 32 bytes. Production reads it from SALT_DNS_VAULT_KEY.
  • :vault_key_id (default "v1"): the label new ciphertexts carry. Production: SALT_DNS_VAULT_KEY_ID.
  • :vault_retired_keys (default %{}): %{key_id => base64 key} of keys that still decrypt old values after a rotation. Production: SALT_DNS_VAULT_RETIRED_KEYS, id:base64 pairs separated by commas.

To rotate: add the old key to the retired keys under its id, set a new key and key id, re-encrypt stored values, then drop the retired key.

Every call takes a context string naming the field (for example "credentials.secret"); see SaltDns.Crypto.

Summary

Functions

The id and value of the active key.

Decrypts a value encrypted with the active key or a retired one.

Encrypts a secret with the active key.

Every key that can still decrypt: the active key and the retired ones, by id.

Functions

active_key()

@spec active_key() :: {binary(), binary()}

The id and value of the active key.

decrypt(ciphertext, context)

@spec decrypt(binary(), binary()) :: {:ok, binary()} | :error

Decrypts a value encrypted with the active key or a retired one.

encrypt(plaintext, context)

@spec encrypt(binary(), binary()) :: {:ok, binary()}

Encrypts a secret with the active key.

keys()

@spec keys() :: %{required(binary()) => binary()}

Every key that can still decrypt: the active key and the retired ones, by id.