cryptoutil

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeySize128 = 16
	KeySize192 = 24
	KeySize256 = 32
)

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(key, ciphertext []byte) ([]byte, error)

func Encrypt

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

func IsValidKeySize

func IsValidKeySize(n int) bool

IsValidKeySize reports whether n is a valid AES key length (128/192/256-bit).

Types

type AESEncryptor

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

AESEncryptor is the default Encryptor, backed by AES-GCM.

func (AESEncryptor) Decrypt

func (e AESEncryptor) Decrypt(ciphertext []byte) ([]byte, error)

func (AESEncryptor) Encrypt

func (e AESEncryptor) Encrypt(plaintext []byte) ([]byte, error)

func (AESEncryptor) IsPlainText

func (e AESEncryptor) IsPlainText() bool

type Encryptor

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

Encryptor abstracts credential encryption so the repository layer never has to know whether it's running with a real key or in plaintext fallback mode.

func NewAESEncryptor

func NewAESEncryptor(key []byte) (Encryptor, error)

NewAESEncryptor validates key and returns an Encryptor backed by AES-GCM.

type NoOpEncryptor

type NoOpEncryptor struct{}

NoOpEncryptor is a plaintext-passthrough Encryptor, used when no encryption key is configured. It exists so "no key configured" degrades to a visible insecure mode instead of a hard startup failure.

func (NoOpEncryptor) Decrypt

func (e NoOpEncryptor) Decrypt(ciphertext []byte) ([]byte, error)

func (NoOpEncryptor) Encrypt

func (e NoOpEncryptor) Encrypt(plaintext []byte) ([]byte, error)

func (NoOpEncryptor) IsPlainText

func (e NoOpEncryptor) IsPlainText() bool

Jump to

Keyboard shortcuts

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