AttestoPhoenix.RefreshSuccessorCipher (AttestoPhoenix v2.7.0)

Copy Markdown View Source

Authenticated encryption for the successor stored during refresh rotation.

The ciphertext format is provided by Plug.Crypto.MessageEncryptor and is intentionally kept here with its existing AAD and derived keys. The application secret is read when encrypting or decrypting so a key change takes effect for both operations without changing the persisted wrapper.

Summary

Functions

Decrypts and safely decodes a refresh-token successor ciphertext.

Derives the encryption and signing keys from a refresh-successor secret.

Encrypts a successor term with the configured refresh-successor secret.

Functions

decrypt(ciphertext)

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

Decrypts and safely decodes a refresh-token successor ciphertext.

Authentication failures and missing or invalid configuration return :error, matching the pre-consolidation call sites.

derive_keys(secret)

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

Derives the encryption and signing keys from a refresh-successor secret.

Kept public so the exact derivation has direct deterministic coverage.

encrypt(successor)

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

Encrypts a successor term with the configured refresh-successor secret.

Returns :error when the secret is missing or too short. The caller owns the persisted version wrapper around the returned ciphertext.