Versions in this module Expand all Collapse all v0 v0.14.0 Nov 30, 2026 Changes in this version + var ErrDecryptionFailed = errors.New("kms: decryption failed") + var ErrInvalidEnvelope = errors.New("kms: invalid encrypted envelope") + var ErrInvalidInput = errors.New("kms: invalid input") + var ErrKeyInactive = errors.New("kms: key version is not active for encryption") + var ErrKeyNotFound = errors.New("kms: key not found") + var ErrVersionNotFound = errors.New("kms: key version not found") + var ErrVersionRetired = errors.New("kms: key version is retired") + func MarshalEnvelope(env EncryptedEnvelope) ([]byte, error) + type DataKey struct + EncryptedKey []byte + KeyID string + KeyVersionID string + Plaintext []byte + func (k *DataKey) Zero() + type EncryptedEnvelope struct + Algorithm string + Ciphertext []byte + CreatedAt time.Time + EncryptedDEK []byte + KeyID string + KeyVersionID string + Nonce []byte + Provider string + Version int + func UnmarshalEnvelope(data []byte) (EncryptedEnvelope, error) + type EnvelopeCipher struct + func NewEnvelopeCipher(provider KeyProvider) (*EnvelopeCipher, error) + func (c *EnvelopeCipher) NeedsRewrap(ctx context.Context, env EncryptedEnvelope) (bool, string, error) + func (c *EnvelopeCipher) Open(ctx context.Context, env EncryptedEnvelope, aad []byte) ([]byte, error) + func (c *EnvelopeCipher) OpenString(ctx context.Context, encoded string, aad []byte) ([]byte, error) + func (c *EnvelopeCipher) Rewrap(ctx context.Context, env EncryptedEnvelope, aad []byte) (EncryptedEnvelope, bool, error) + func (c *EnvelopeCipher) RewrapBatch(ctx context.Context, envs []EncryptedEnvelope, ...) ([]EncryptedEnvelope, RewrapStats, error) + func (c *EnvelopeCipher) Seal(ctx context.Context, keyID string, plaintext, aad []byte) (EncryptedEnvelope, error) + func (c *EnvelopeCipher) SealString(ctx context.Context, keyID string, plaintext, aad []byte) (string, error) + type KeyMetadata struct + ActiveVersionID string + Algorithm string + KeyID string + Provider string + Versions []KeyVersionInfo + type KeyProvider interface + Decrypt func(ctx context.Context, keyID, keyVersionID string, ciphertext, aad []byte) ([]byte, error) + DescribeKey func(ctx context.Context, keyID string) (KeyMetadata, error) + Encrypt func(ctx context.Context, keyID string, plaintext, aad []byte) (keyVersionID string, ciphertext []byte, err error) + GenerateDataKey func(ctx context.Context, keyID string, aad []byte) (DataKey, error) + ProviderName func() string + ReEncrypt func(ctx context.Context, keyID, sourceVersionID string, ciphertext, aad []byte) (newVersionID string, newCiphertext []byte, err error) + type KeyState string + const KeyStateActive + const KeyStateDecryptOnly + const KeyStateRetired + type KeyVersionInfo struct + CreatedAt time.Time + State KeyState + VersionID string + type LocalKeySeed struct + CreatedAt time.Time + Key []byte + KeyID string + State KeyState + VersionID string + type LocalKeyring struct + func NewLocalKeyring(seeds ...LocalKeySeed) (*LocalKeyring, error) + func NewLocalKeyringWithGeneratedKey(keyID string) (*LocalKeyring, error) + func (k *LocalKeyring) AddKeyVersion(seed LocalKeySeed) error + func (k *LocalKeyring) Decrypt(ctx context.Context, keyID, keyVersionID string, ciphertext, aad []byte) ([]byte, error) + func (k *LocalKeyring) DescribeKey(ctx context.Context, keyID string) (KeyMetadata, error) + func (k *LocalKeyring) Encrypt(ctx context.Context, keyID string, plaintext, aad []byte) (string, []byte, error) + func (k *LocalKeyring) GenerateDataKey(ctx context.Context, keyID string, aad []byte) (DataKey, error) + func (k *LocalKeyring) ImportBase64Key(keyID, versionID, encoded string, state KeyState) error + func (k *LocalKeyring) ImportHexKey(keyID, versionID, encoded string, state KeyState) error + func (k *LocalKeyring) ProviderName() string + func (k *LocalKeyring) ReEncrypt(ctx context.Context, keyID, sourceVersionID string, ciphertext, aad []byte) (string, []byte, error) + func (k *LocalKeyring) RetireKeyVersion(ctx context.Context, keyID, versionID string) error + func (k *LocalKeyring) RotateKey(ctx context.Context, keyID string, newKeyMaterial []byte) (KeyMetadata, error) + func (k *LocalKeyring) RotateKeyWithVersion(ctx context.Context, keyID, versionID string, newKeyMaterial []byte) (KeyMetadata, error) + type ProviderRegistry struct + func NewProviderRegistry() *ProviderRegistry + func (r *ProviderRegistry) Get(name string) (KeyProvider, bool) + func (r *ProviderRegistry) Register(p KeyProvider) error + type RewrapStats struct + Rewrapped int + Total int + Unchanged int + type RotatableKeyProvider interface + RetireKeyVersion func(ctx context.Context, keyID, versionID string) error + RotateKey func(ctx context.Context, keyID string, newKeyMaterial []byte) (KeyMetadata, error)