cryptoutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AESKey []byte

AESKey is the global AES-256 key set by InitKey at startup.

Functions

func Decrypt

func Decrypt(encrypted string, key []byte) (string, error)

Decrypt decrypts a value produced by Encrypt. If the value does not start with "enc:" it is returned unchanged (passthrough).

func Encrypt

func Encrypt(plaintext string, key []byte) (string, error)

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

func InitKey(salt []byte) error

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.

Jump to

Keyboard shortcuts

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