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 ¶
const KeySize = 32
KeySize is the AES-256 key length in bytes.
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).
const SerializerName = "credential_cipher"
SerializerName is the GORM serializer tag value for encrypted columns.
Variables ¶
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 InstallConfigured ¶
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.