mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
90b88e1cf9
In the light of extending our eKMS support it will be helpful to have a tighter use of the word "KMS". KMS should refer to the actual component that manages keys. The keyservice, also called KMS in the constellation code, does not manage keys itself. It talks to a KMS backend, which in turn does the actual key management.
39 lines
866 B
Go
39 lines
866 B
Go
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
package storage
|
|
|
|
import "context"
|
|
|
|
// MemMapStorage is the standard implementation of the Storage interface, storing keys in memory only.
|
|
type MemMapStorage struct {
|
|
dekPool map[string][]byte
|
|
}
|
|
|
|
// NewMemMapStorage creates and initialises a new MemMapStorage object.
|
|
func NewMemMapStorage() *MemMapStorage {
|
|
s := &MemMapStorage{
|
|
dekPool: make(map[string][]byte),
|
|
}
|
|
|
|
return s
|
|
}
|
|
|
|
// Get returns a DEK from MemMapStorage by key ID.
|
|
func (s *MemMapStorage) Get(ctx context.Context, keyID string) ([]byte, error) {
|
|
encDEK, ok := s.dekPool[keyID]
|
|
if ok {
|
|
return encDEK, nil
|
|
}
|
|
return nil, ErrDEKUnset
|
|
}
|
|
|
|
// Put saves a DEK to MemMapStorage by key ID.
|
|
func (s *MemMapStorage) Put(ctx context.Context, keyID string, encDEK []byte) error {
|
|
s.dekPool[keyID] = encDEK
|
|
return nil
|
|
}
|