Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AESKey []byte
AESKey is the global AES-256 key set by InitKey at startup.
Functions ¶
func Decrypt ¶
Decrypt decrypts a value produced by Encrypt. If the value does not start with "enc:" it is returned unchanged (passthrough).
func Encrypt ¶
Encrypt encrypts plaintext with AES-256-GCM and returns "enc:<base64(nonce+ciphertext)>". nonce is 12 random bytes prepended to the ciphertext before base64 encoding.
func InitKey ¶
InitKey derives the AES-256 key from config.Conf.Encryption.SecretKey.
The operator picks the value: any passphrase is accepted and run through scrypt to produce the 32 bytes AES-256 needs. Nothing is padded and nothing is truncated, so nothing the operator typed is silently discarded or silently ignored — a key nobody chose is the failure this replaces.
The key is never generated and never written back. A key this server invents is a key the operator does not have, and every credential encrypted under it dies with the container. An absent value is a startup failure, reported here and acted on by the caller.
salt is this deployment's own salt, from db.EncryptionSalt. It is what keeps the derived key specific to this database even when two deployments share a passphrase.
Types ¶
This section is empty.