Documentation
¶
Overview ¶
Package testutil provides test helpers for encryption testing.
Index ¶
- func NewTestKeyring() systemkey.Keyring
- type InMemoryKeyStore
- func (s *InMemoryKeyStore) CreateKey(_ context.Context, scope, scopeID string, version int, encryptedDEK []byte, ...) error
- func (s *InMemoryKeyStore) DestroyKeys(_ context.Context, scope, scopeID string) error
- func (s *InMemoryKeyStore) GetActiveKey(_ context.Context, scope, scopeID string) (*keystore.EncryptedKey, error)
- func (s *InMemoryKeyStore) GetKey(_ context.Context, scope, scopeID string, version int) (*keystore.EncryptedKey, error)
- func (s *InMemoryKeyStore) RevokeKeys(_ context.Context, scope, scopeID string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTestKeyring ¶
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).