encryption

package
v0.6.35 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: Apache-2.0 Imports: 6 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package encryption provides encryption and decryption functions, while abstracting away key management concerns. Uses AES-GCM encryption, with key rotation, keeping keys in memory.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyNotFound = errors.New("data key not found")
)

Functions

This section is empty.

Types

type Manager

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

Manager uses AES-GCM encryption and keeps in memory the data encryption keys. The active encryption key is automatically rotated once it has been used over a certain amount of times - defined by maxWriteCount.

func NewManager

func NewManager() (*Manager, error)

NewManager returns Manager, which satisfies db.Encryptor and db.Decryptor

func (*Manager) Decrypt

func (m *Manager) Decrypt(edata, nonce []byte, keyID uint32) ([]byte, error)

Decrypt accepts a chunk of encrypted data, the nonce used to encrypt it and the ID of the used key (as it rotates). It returns the decrypted data or an error.

func (*Manager) Encrypt

func (m *Manager) Encrypt(data []byte) ([]byte, []byte, uint32, error)

Encrypt encrypts the specified data, returning: the encrypted data, the nonce used to encrypt the data, and an ID identifying the key that was used (as it rotates). On failure error is returned instead.

Jump to

Keyboard shortcuts

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