local

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package local implements an in-process symmetric kek.Wrapper using a cipher.Cipher (AES-256-GCM by default) and provides in-memory and file-based KEK loaders.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewKeyringFromFiles

func NewKeyringFromFiles(cfg FileConfig, opts ...Option) (kek.Keyring, error)

NewKeyringFromFiles reads base64-encoded keys from the configured file paths and returns a kek.Keyring.

func NewKeyringFromMap

func NewKeyringFromMap(keys map[string][]byte, activeKeyID string, opts ...Option) (kek.Keyring, error)

NewKeyringFromMap constructs a kek.Keyring from a map of key IDs to raw key bytes.

Types

type FileConfig

type FileConfig struct {
	// KeyPaths maps KEK IDs to file paths containing base64-encoded keys.
	KeyPaths    map[string]string
	ActiveKeyID string
}

FileConfig holds the configuration for loading local KEKs from files.

type Option

type Option func(*Wrapper)

Option configures a local Wrapper.

func WithCipher

func WithCipher(c cipher.Cipher) Option

WithCipher overrides the default AES-256-GCM cipher used to wrap/unwrap DEKs.

type Wrapper

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

Wrapper implements kek.Wrapper in-process using a symmetric key and cipher.Cipher. Safe for concurrent use.

func NewWrapper

func NewWrapper(id string, rawKey []byte, opts ...Option) (*Wrapper, error)

NewWrapper creates an in-process KEK Wrapper with a defensive copy of rawKey.

func (*Wrapper) Close

func (w *Wrapper) Close()

Close scrubs the local KEK bytes from memory and marks the wrapper as closed.

func (*Wrapper) ID

func (w *Wrapper) ID() string

ID returns the unique identifier of this KEK.

func (*Wrapper) Unwrap

func (w *Wrapper) Unwrap(_ context.Context, encryptedDEK, aad []byte) ([]byte, error)

Unwrap decrypts an encrypted DEK with the local KEK and verifies aad.

func (*Wrapper) Wrap

func (w *Wrapper) Wrap(_ context.Context, dek, aad []byte) ([]byte, error)

Wrap encrypts a plaintext DEK with the local KEK and binds it to aad.

Jump to

Keyboard shortcuts

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