Files
threshold/internal/kms/rewrapping.go
shadowdaoandClaude Sonnet 5.5 962d708fdd Rename Go module paths to repo.anhonesthost.net/CyberCoveLLC/threshold
Rename root, api and sdk module paths (imports, go.mod, go_package,
ldflags, build scripts, buf configs) and regenerate protobuf/gateway
code with the project's pinned toolchain. Wire identifiers unchanged.
api gets a local replace for sdk; root/api/sdk require v0.1.0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 10:33:41 -07:00

38 lines
1.2 KiB
Go

// Copyright IBM Corp. 2020, 2026
// SPDX-License-Identifier: BUSL-1.1
package kms
import (
"context"
"fmt"
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/db"
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
"golang.org/x/exp/maps"
)
// GetWrapperer defines (and constrains) the kms features required by the
// RewrapFn
type GetWrapperer interface {
// GetWrapper returns a wrapper for the given scope and purpose.
GetWrapper(ctx context.Context, scopeId string, purpose KeyPurpose, opt ...Option) (wrapping.Wrapper, error)
}
type RewrapFn func(ctx context.Context, dataKeyVersionId string, scopeId string, reader db.Reader, writer db.Writer, kms GetWrapperer) error
var tableNameToRewrapFn = map[string]RewrapFn{}
// RegisterTableRewrapFn registers a function to be used to rewrap data in a specific table with a new key
func RegisterTableRewrapFn(tableName string, rewrapFn RewrapFn) {
if _, ok := tableNameToRewrapFn[tableName]; ok {
panic(fmt.Sprintf("rewrap function for table name %q already exists", tableName))
}
tableNameToRewrapFn[tableName] = rewrapFn
}
// ListTablesSupportingRewrap lists all the table names registered with a rewrap function
func ListTablesSupportingRewrap() []string {
return maps.Keys(tableNameToRewrapFn)
}