testutil

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package testutil provides test helpers for encryption testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTestKeyring

func NewTestKeyring() systemkey.Keyring

NewTestKeyring creates an in-memory keyring with a random 32-byte test key. The active key ID is "test-key-1".

Types

type InMemoryKeyStore

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

InMemoryKeyStore implements keystore.KeyStore using an in-memory map. Safe for concurrent use. Intended for unit testing only.

func NewInMemoryKeyStore

func NewInMemoryKeyStore() *InMemoryKeyStore

NewInMemoryKeyStore creates a new in-memory key store.

func (*InMemoryKeyStore) CreateKey

func (s *InMemoryKeyStore) CreateKey(_ context.Context, scope, scopeID string, version int, encryptedDEK []byte, systemKeyID string) error

CreateKey appends a new EncryptedKey to the store.

func (*InMemoryKeyStore) DestroyKeys

func (s *InMemoryKeyStore) DestroyKeys(_ context.Context, scope, scopeID string) error

DestroyKeys removes all keys for scope:scopeID.

func (*InMemoryKeyStore) GetActiveKey

func (s *InMemoryKeyStore) GetActiveKey(_ context.Context, scope, scopeID string) (*keystore.EncryptedKey, error)

GetActiveKey returns the latest non-revoked key by highest KeyVersion.

func (*InMemoryKeyStore) GetKey

func (s *InMemoryKeyStore) GetKey(_ context.Context, scope, scopeID string, version int) (*keystore.EncryptedKey, error)

GetKey returns the key with the exact version.

func (*InMemoryKeyStore) RevokeKeys

func (s *InMemoryKeyStore) RevokeKeys(_ context.Context, scope, scopeID string) error

RevokeKeys marks all non-revoked keys for scope:scopeID as revoked, except the one with the highest version (the active key).

Jump to

Keyboard shortcuts

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