dekstore

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

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 dekstore provides a thin database layer for vault and kms encryption providers to manage their wrapped DEK record in the application database. Supports both postgres and mongo backends, matching cfg.DatastoreType.

Schema: one row per provider. wrapped_deks[0] is the primary DEK (newest); subsequent elements are legacy keys kept for decryption-only rotation. revision enables optimistic updates so a future key-rotation CLI can safely prepend a new wrapped DEK without clobbering a concurrent update.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Record

type Record struct {
	// WrappedDEKs holds backend-wrapped DEK ciphertexts.
	// Index 0 is the primary (used for new encryptions); subsequent entries
	// are legacy keys retained for decryption-only key rotation.
	WrappedDEKs [][]byte
	// Revision is incremented on every update. Used for optimistic locking.
	Revision int64
}

Record is the single DEK record stored per encryption provider.

type Store

type Store interface {
	// Load returns the record for provider, or nil if none exists.
	Load(ctx context.Context, provider string) (*Record, error)

	// Bootstrap inserts the initial record if no row exists for provider.
	// On primary-key conflict (another instance beat us) it silently succeeds;
	// the caller must Load again to obtain the winning record.
	Bootstrap(ctx context.Context, provider string, wrappedDEK []byte) error

	// Update replaces wrapped_deks and increments revision, but only when the
	// stored revision equals oldRevision (optimistic locking). Returns true if
	// the update was applied, false if the revision was stale.
	Update(ctx context.Context, provider string, wrappedDEKs [][]byte, oldRevision int64) (bool, error)

	// Close releases the underlying connection.
	Close()
}

Store manages a single DEK record per provider name.

func New

func New(cfg *config.Config) (Store, error)

New opens a minimal connection and returns a Store based on cfg.DatastoreType.

Jump to

Keyboard shortcuts

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