credentialcipher

package
v0.6.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package credentialcipher encrypts stored credential data at rest with AES-256-GCM. One key serves the whole process: Install sets it before the databases open, and the credential_cipher GORM serializer seals every credentials.data write and opens every read. Without an installed key the serializer fails instead of writing plaintext.

Index

Constants

View Source
const KeySize = 32

KeySize is the AES-256 key length in bytes.

View Source
const SealedPrefix = "llmr-enc:v1:"

SealedPrefix marks an encrypted value: the version selects the algorithm (v1 = AES-256-GCM, 12-byte nonce prepended to the ciphertext).

View Source
const SerializerName = "credential_cipher"

SerializerName is the GORM serializer tag value for encrypted columns.

Variables

View Source
var (
	// ErrKeyMissing reports a seal or open attempt before Install.
	ErrKeyMissing = errors.New("credential encryption key is not installed")
	// ErrNotSealed reports a stored value without the sealed prefix.
	ErrNotSealed = errors.New("credential data is not encrypted")
	// ErrInvalidKey reports a key of the wrong length or encoding.
	ErrInvalidKey = errors.New("credential encryption key must be 32 bytes, base64-encoded")
)

Functions

func Install

func Install(key []byte) error

Install sets the process key. Later calls replace it.

func InstallConfigured

func InstallConfigured(encodedKey, keyFile string) (created bool, err error)

InstallConfigured installs the key from encodedKey (base64) when set, otherwise from keyFile, creating keyFile with a fresh random key (mode 0600) when it does not exist. created reports a newly generated file.

Types

type Cipher

type Cipher struct {
	// contains filtered or unexported fields
}

Cipher seals and opens credential payloads with one AES-256-GCM key.

func Current

func Current() (*Cipher, error)

Current returns the installed cipher or ErrKeyMissing.

func New

func New(key []byte) (*Cipher, error)

New builds a Cipher from a raw 32-byte key.

func (*Cipher) Open

func (c *Cipher) Open(value string) ([]byte, error)

Open decrypts a value produced by Seal.

func (*Cipher) Seal

func (c *Cipher) Seal(plaintext []byte) (string, error)

Seal encrypts plaintext into a prefixed, base64 text value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL