memory

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package memory provides in-memory providers for tests and examples.

They are not for production: key material is held in process memory only, nothing persists, and no root key protects it. Their purpose is to exercise the client and the control plane against both styles of provider keyforge has to support:

  • NewKeyring behaves like the local keyring: it holds every version itself and numbers them 1, 2, 3 and so on.
  • NewNative behaves like a managed key service: the service assigns version numbers, which only increase and are not consecutive, and a wrapped key records the version that wrapped it.

A caller that assumes the next version is the previous plus one passes against the first and fails against the second.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Provider)

Option configures a Provider.

func WithEntropy

func WithEntropy(r io.Reader) Option

WithEntropy sets the source of key material and identifiers. The default is crypto/rand. Tests inject a deterministic reader.

func WithName

func WithName(name string) Option

WithName sets the provider's name, which is the Provider field of every key reference it returns. The default is "memory-keyring" or "memory-native".

type Provider

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

Provider is an in-memory provider.Provider.

func NewKeyring

func NewKeyring(opts ...Option) *Provider

NewKeyring returns a provider that behaves like the local keyring.

func NewNative

func NewNative(opts ...Option) *Provider

NewNative returns a provider that behaves like a managed key service.

func (*Provider) CreateKey

func (p *Provider) CreateKey(ctx context.Context, spec provider.KeySpec) (provider.KeyRef, error)

CreateKey implements provider.Provider.

func (*Provider) Destroy

func (p *Provider) Destroy(ctx context.Context, ref provider.KeyRef, ver uint32) error

Destroy implements provider.Provider.

func (*Provider) Health

func (p *Provider) Health(ctx context.Context) error

Health implements provider.Provider.

func (*Provider) Name

func (p *Provider) Name() string

Name implements provider.Provider.

func (*Provider) Rotate

func (p *Provider) Rotate(ctx context.Context, ref provider.KeyRef) (uint32, error)

Rotate implements provider.Provider.

func (*Provider) Unwrap

func (p *Provider) Unwrap(ctx context.Context, ref provider.KeyRef, ver uint32, wrapped, aad []byte) ([]byte, error)

Unwrap implements provider.Provider.

func (*Provider) Wrap

func (p *Provider) Wrap(ctx context.Context, ref provider.KeyRef, ver uint32, dek, aad []byte) ([]byte, error)

Wrap implements provider.Provider.

Jump to

Keyboard shortcuts

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