crypto

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package crypto provides field-level encryption for fabriq (e.g. blob_source credentials). It is core-pure: stdlib only, zero TwinOS knowledge.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotConfigured is returned by callers when encryption is required but no
	// key was configured.
	ErrNotConfigured = errors.New("fabriq: encryption not configured")
	// ErrKeyVersion is returned when a ciphertext's key-version byte is unknown.
	ErrKeyVersion = errors.New("fabriq: ciphertext key version not recognized")
)

Functions

This section is empty.

Types

type AESGCM

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

AESGCM implements Encryptor with AES-256-GCM. Envelope layout:

[1-byte keyVersion][12-byte nonce][ciphertext+tag]

func NewAESGCM

func NewAESGCM(key []byte) (*AESGCM, error)

NewAESGCM builds an AES-256-GCM encryptor from a 32-byte key.

func (*AESGCM) Decrypt

func (a *AESGCM) Decrypt(ciphertext, aad []byte) ([]byte, error)

Decrypt opens an envelope produced by Encrypt, verifying aad.

func (*AESGCM) Encrypt

func (a *AESGCM) Encrypt(plaintext, aad []byte) ([]byte, error)

Encrypt seals plaintext with a fresh random nonce, binding aad. The returned envelope is version || nonce || ciphertext+tag.

type Encryptor

type Encryptor interface {
	Encrypt(plaintext, aad []byte) ([]byte, error)
	Decrypt(ciphertext, aad []byte) ([]byte, error)
}

Encryptor encrypts and decrypts opaque byte fields. aad (additional authenticated data) binds the ciphertext to its context (e.g. the tenant id) so a stolen ciphertext cannot be replayed into another row; the SAME aad must be supplied to Decrypt.

Jump to

Keyboard shortcuts

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