kms

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package kms is doze-aws's local Key Management Service with real crypto for all three key families:

  • SYMMETRIC_DEFAULT keys encrypt/decrypt via AES-256-GCM with the encryption context bound as authenticated data; the ciphertext blob embeds the key id (like real KMS), so Decrypt needs no KeyId.
  • RSA_2048/3072/4096 and ECC_NIST_P256/P384/P521 keys really sign/verify (RSASSA_PKCS1_V1_5, RSASSA_PSS, ECDSA) and RSA keys really encrypt/decrypt (RSAES_OAEP_SHA_1/SHA_256); GetPublicKey returns the genuine DER SPKI, so signatures verify outside KMS too.
  • HMAC_224/256/384/512 keys really GenerateMac/VerifyMac.

Application crypto code works unmodified. ECC_SECG_P256K1 (secp256k1) is the one spec that answers UnsupportedOperationException — Go's standard library has no secp256k1, and doze-aws does not take crypto dependencies.

See docs/api-support/kms.md for the operation-by-operation support table.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key struct {
	ID           string            `json:"id"` // UUID
	Material     []byte            `json:"material"`
	OldMaterials [][]byte          `json:"old_materials,omitempty"` // superseded backing keys, newest first, kept so pre-rotation ciphertexts still decrypt
	Rotations    []int64           `json:"rotations,omitempty"`     // unix-seconds timestamps of each rotation, newest first
	State        string            `json:"state"`
	Description  string            `json:"description"`
	Created      int64             `json:"created"`               // unix seconds
	DeletionAt   int64             `json:"deletion_at,omitempty"` // unix seconds, PendingDeletion only
	RotationOn   bool              `json:"rotation_on"`           // automatic-rotation flag
	Policy       string            `json:"policy,omitempty"`      // round-trip only
	Tags         map[string]string `json:"tags,omitempty"`
	KeySpec      string            `json:"key_spec"`  // SYMMETRIC_DEFAULT
	KeyUsage     string            `json:"key_usage"` // ENCRYPT_DECRYPT
	MultiRegion  bool              `json:"multi_region"`
}

Key is one customer master key.

func (*Key) ARN

func (k *Key) ARN() string

ARN returns the key's ARN.

type Options

type Options struct {
	// DataDir holds the bbolt store (kms.bolt). Required.
	DataDir string
	// Peers is accepted for constructor uniformity; KMS calls no siblings.
	Peers peers.Directory
	// Logf receives log lines; nil discards.
	Logf func(format string, args ...any)
	// Clock overrides time.Now in tests.
	Clock func() time.Time
}

Options configures the service.

type Server

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

Server is the KMS service: an http.Handler speaking AWS JSON 1.1, and an io.Closer that stops the janitor and closes the store.

func New

func New(opts Options) (*Server, error)

New opens the bbolt store under DataDir and starts the deletion janitor.

func (*Server) Close

func (s *Server) Close() error

Close stops the janitor and closes the bbolt DB.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Store

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

Store is the bbolt-backed KMS state.

func (*Store) Aliases

func (s *Store) Aliases() ([][2]string, error)

Aliases returns name→keyID, sorted by name.

func (*Store) CreateKey

func (s *Store) CreateKey(spec, usage, description, policy string, tags map[string]string) (*Key, error)

CreateKey mints a new key of the given spec. Material is the AES key (symmetric), the HMAC secret, or the PKCS#8 DER private key (RSA/ECC).

func (*Store) DeleteAlias

func (s *Store) DeleteAlias(name string) error

DeleteAlias removes an alias.

func (*Store) List

func (s *Store) List() ([]Key, error)

List returns all keys, sorted by id.

func (*Store) Resolve

func (s *Store) Resolve(ident string) (*Key, error)

Resolve maps any accepted key identifier — key id, key ARN, alias name, alias ARN — to the key.

func (*Store) SetAlias

func (s *Store) SetAlias(name, keyIdent string, mustExist, mustNotExist bool) error

SetAlias points an alias at a key (create or update).

func (*Store) SweepDeletions

func (s *Store) SweepDeletions()

SweepDeletions finalizes PendingDeletion keys whose date has passed.

func (*Store) Update

func (s *Store) Update(ident string, fn func(*Key) *awshttp.APIError) (*Key, error)

Update applies fn to a key resolved by ident and persists it.

Jump to

Keyboard shortcuts

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