Documentation ¶
Overview ¶
Package materials provides CryptoMaterialsManager implementations.
The cryptographic materials manager (CMM) assembles the cryptographic materials that are used to encrypt and decrypt data.
Supported Cryptographic Materials Managers ¶
- DefaultCryptoMaterialsManager: A default interacts with your Master Key Providers without any caching.
- CachingCryptoMaterialsManager: A caching CMM that uses a cache to store cryptographic materials. Not implemented yet.
Usage ¶
The following example demonstrates how to use the DefaultCryptoMaterialsManager.
// Set up your key provider. cmm, err := materials.NewDefault(keyProvider) if err != nil { panic("materials manager setup failed") // handle error }
Check example for more advanced usage.
Index ¶
- Constants
- Variables
- type BaseCache
- type CacheEntry
- type CachingCryptoMaterialsManager
- func (cm *CachingCryptoMaterialsManager) DecryptMaterials(_ context.Context, _ model.DecryptionMaterialsRequest) (model.DecryptionMaterial, error)
- func (cm *CachingCryptoMaterialsManager) GetEncryptionMaterials(_ context.Context, _ model.EncryptionMaterialsRequest) (model.EncryptionMaterial, error)
- func (cm *CachingCryptoMaterialsManager) GetInstance() model.CryptoMaterialsManager
- type DefaultCryptoMaterialsManager
- func (dm *DefaultCryptoMaterialsManager) DecryptMaterials(ctx context.Context, decReq model.DecryptionMaterialsRequest) (model.DecryptionMaterial, error)
- func (dm *DefaultCryptoMaterialsManager) GetEncryptionMaterials(ctx context.Context, encReq model.EncryptionMaterialsRequest) (model.EncryptionMaterial, error)
- func (dm *DefaultCryptoMaterialsManager) GetInstance() model.CryptoMaterialsManager
- type MemoryCache
- func (mc *MemoryCache) GetDecryptionEntry(key []byte) (*CacheEntry[model.DecryptionMaterials], error)
- func (mc *MemoryCache) GetEncryptionEntry(key []byte, _ int) (*CacheEntry[model.EncryptionMaterials], error)
- func (mc *MemoryCache) PutDecryptionEntry(key []byte, dm model.DecryptionMaterials) (*CacheEntry[model.DecryptionMaterials], error)
- func (mc *MemoryCache) PutEncryptionEntry(key []byte, em model.EncryptionMaterials, _ int) (*CacheEntry[model.EncryptionMaterials], error)
Constants ¶
const EcPublicKeyField = "aws-crypto-public-key"
EcPublicKeyField is the reserved field name in encryption context that represents the public verification key.
Variables ¶
var ErrCMM = errors.New("CMM error")
ErrCMM is a generic model.CryptoMaterialsManager error.
Functions ¶
This section is empty.
Types ¶
type BaseCache ¶
type BaseCache interface { PutEncryptionEntry(cacheKey []byte, m model.EncryptionMaterials, n int) (*CacheEntry[model.EncryptionMaterials], error) PutDecryptionEntry(cacheKey []byte, m model.DecryptionMaterials) (*CacheEntry[model.DecryptionMaterials], error) GetEncryptionEntry(cacheKey []byte, n int) (*CacheEntry[model.EncryptionMaterials], error) GetDecryptionEntry(cacheKey []byte) (*CacheEntry[model.DecryptionMaterials], error) }
BaseCache CachingCryptoMaterialsManager still under development.
type CacheEntry ¶
type CacheEntry[V model.EncryptionMaterials | model.DecryptionMaterials] struct { // contains filtered or unexported fields }
CacheEntry CachingCryptoMaterialsManager still under development.
func NewCacheEntry ¶
func NewCacheEntry[V model.EncryptionMaterials | model.DecryptionMaterials](key []byte, value V, lifetime time.Duration) *CacheEntry[V]
NewCacheEntry CachingCryptoMaterialsManager still under development.
func (*CacheEntry[V]) Age ¶
func (ce *CacheEntry[V]) Age() float64
func (*CacheEntry[V]) IsTooOld ¶
func (ce *CacheEntry[V]) IsTooOld() bool
func (*CacheEntry[V]) Key ¶
func (ce *CacheEntry[V]) Key() []byte
func (*CacheEntry[V]) Value ¶
func (ce *CacheEntry[V]) Value() V
type CachingCryptoMaterialsManager ¶
type CachingCryptoMaterialsManager struct {
// contains filtered or unexported fields
}
CachingCryptoMaterialsManager still under development.
func NewCaching ¶
func NewCaching(cache BaseCache, _ model.MasterKeyProvider, _ ...model.MasterKeyProvider) (*CachingCryptoMaterialsManager, error)
NewCaching CachingCryptoMaterialsManager still under development.
func (*CachingCryptoMaterialsManager) DecryptMaterials ¶
func (cm *CachingCryptoMaterialsManager) DecryptMaterials(_ context.Context, _ model.DecryptionMaterialsRequest) (model.DecryptionMaterial, error)
DecryptMaterials CachingCryptoMaterialsManager still under development.
func (*CachingCryptoMaterialsManager) GetEncryptionMaterials ¶
func (cm *CachingCryptoMaterialsManager) GetEncryptionMaterials(_ context.Context, _ model.EncryptionMaterialsRequest) (model.EncryptionMaterial, error)
GetEncryptionMaterials CachingCryptoMaterialsManager still under development.
func (*CachingCryptoMaterialsManager) GetInstance ¶
func (cm *CachingCryptoMaterialsManager) GetInstance() model.CryptoMaterialsManager
GetInstance CachingCryptoMaterialsManager still under development.
type DefaultCryptoMaterialsManager ¶
type DefaultCryptoMaterialsManager struct {
// contains filtered or unexported fields
}
DefaultCryptoMaterialsManager is a default implementation of model.CryptoMaterialsManager. It interacts directly with your Master Key Providers without any caching.
func NewDefault ¶
func NewDefault(primary model.MasterKeyProvider, extra ...model.MasterKeyProvider) (*DefaultCryptoMaterialsManager, error)
NewDefault creates a new instance of DefaultCryptoMaterialsManager.
It takes a primary model.MasterKeyProvider and an optional list of extra MasterKeyProviders as parameters. If the primary MasterKeyProvider is nil, it returns an error.
Parameters:
- primary: The primary model.MasterKeyProvider. Must not be nil.
- extra: Optional additional model.MasterKeyProvider providers. Duplicates are not allowed.
func (*DefaultCryptoMaterialsManager) DecryptMaterials ¶
func (dm *DefaultCryptoMaterialsManager) DecryptMaterials(ctx context.Context, decReq model.DecryptionMaterialsRequest) (model.DecryptionMaterial, error)
DecryptMaterials returns the decryption materials for the given request. Used during decryption process to get the decryption materials from registered master key providers.
func (*DefaultCryptoMaterialsManager) GetEncryptionMaterials ¶
func (dm *DefaultCryptoMaterialsManager) GetEncryptionMaterials(ctx context.Context, encReq model.EncryptionMaterialsRequest) (model.EncryptionMaterial, error)
GetEncryptionMaterials returns the encryption materials for the given request. Used during encryption process to get the encryption materials from registered master key providers.
func (*DefaultCryptoMaterialsManager) GetInstance ¶
func (dm *DefaultCryptoMaterialsManager) GetInstance() model.CryptoMaterialsManager
GetInstance returns a new instance of the crypto materials manager to interact within encryption/decryption process.
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache CachingCryptoMaterialsManager still under development.
func (*MemoryCache) GetDecryptionEntry ¶
func (mc *MemoryCache) GetDecryptionEntry(key []byte) (*CacheEntry[model.DecryptionMaterials], error)
func (*MemoryCache) GetEncryptionEntry ¶
func (mc *MemoryCache) GetEncryptionEntry(key []byte, _ int) (*CacheEntry[model.EncryptionMaterials], error)
func (*MemoryCache) PutDecryptionEntry ¶
func (mc *MemoryCache) PutDecryptionEntry(key []byte, dm model.DecryptionMaterials) (*CacheEntry[model.DecryptionMaterials], error)
func (*MemoryCache) PutEncryptionEntry ¶
func (mc *MemoryCache) PutEncryptionEntry(key []byte, em model.EncryptionMaterials, _ int) (*CacheEntry[model.EncryptionMaterials], error)