Documentation ¶
Overview ¶
Package filesystem implements keystores that write and reads keys from file system. Each keystore is responsible for generating keys for specific service, writing them to provided file path, reading and decrypting them. Server keystore generates AcraServer transport key pair and AcraStorage encryption keypair used for creating/decrypting AcraStructs. Connector keystore generates AcraConnector transport key pair. Translator keystore generates AcraTranslator transport key pair.
Index ¶
- Constants
- Variables
- func DescribeKeyFile(fileName string) (*keystore.KeyDescription, error)
- func GetServerDecryptionKeyFilename(id []byte) string
- func IsKeyDirectory(keyDirectory string, extractor *args.ServiceExtractor) bool
- func IsKeyReadError(err error) bool
- func ReadDir(storage Storage, path string) ([]string, error)
- type DefaultKeyFileClassifier
- type DummyStorage
- type ExportedKey
- func EnumerateExportedKeys(enumerator KeyExportEnumerator) ([]ExportedKey, error)
- func EnumerateExportedKeysByClass(enumerator KeyExportEnumerator, classifier KeyFileClassifier) ([]ExportedKey, error)
- func NewExportedPlaintextSymmetricKey(symmetricPath string, keyContext keystore.KeyContext) *ExportedKey
- func NewExportedPrivateKey(privatePath string, keyContext keystore.KeyContext) *ExportedKey
- func NewExportedPublicKey(publicPath string, keyContext keystore.KeyContext) *ExportedKey
- func NewExportedSymmetricKey(symmetricPath string, keyContext keystore.KeyContext) *ExportedKey
- type FileStorage
- func (*FileStorage) Copy(src, dst string) error
- func (*FileStorage) Exists(path string) (bool, error)
- func (*FileStorage) Link(oldpath, newpath string) error
- func (*FileStorage) MkdirAll(path string, perm os.FileMode) error
- func (*FileStorage) ReadDir(path string) ([]os.FileInfo, error)
- func (*FileStorage) ReadFile(path string) ([]byte, error)
- func (*FileStorage) Remove(path string) error
- func (*FileStorage) RemoveAll(path string) error
- func (*FileStorage) Rename(oldpath, newpath string) error
- func (*FileStorage) Stat(path string) (os.FileInfo, error)
- func (*FileStorage) TempDir(pattern string, perm os.FileMode) (string, error)
- func (*FileStorage) TempFile(pattern string, perm os.FileMode) (string, error)
- func (*FileStorage) WriteFile(path string, data []byte, perm os.FileMode) error
- type KeyBackuper
- type KeyExport
- type KeyExportEnumerator
- type KeyFileClassifier
- type KeyStore
- func NewFileSystemKeyStoreWithCacheSize(directory string, encryptor keystore.KeyEncryptor, cacheSize int) (*KeyStore, error)
- func NewFilesystemKeyStore(directory string, encryptor keystore.KeyEncryptor) (*KeyStore, error)
- func NewFilesystemKeyStoreTwoPath(privateKeyFolder, publicKeyFolder string, encryptor keystore.KeyEncryptor) (*KeyStore, error)
- func (store *KeyStore) Add(keyID string, keyValue []byte)
- func (store *KeyStore) CacheOnStart() error
- func (store *KeyStore) DestroyClientIDEncryptionKeyPair(clientID []byte) error
- func (store *KeyStore) DestroyClientIDSymmetricKey(clientID []byte) error
- func (store *KeyStore) DestroyHmacSecretKey(clientID []byte) error
- func (store *KeyStore) DestroyPoisonKeyPair() error
- func (store *KeyStore) DestroyPoisonSymmetricKey() error
- func (store *KeyStore) DestroyRotatedClientIDEncryptionKeyPair(clientID []byte, index int) error
- func (store *KeyStore) DestroyRotatedClientIDSymmetricKey(clientID []byte, index int) error
- func (store *KeyStore) DestroyRotatedHmacSecretKey(clientID []byte, index int) error
- func (store *KeyStore) DestroyRotatedPoisonKeyPair(index int) error
- func (store *KeyStore) DestroyRotatedPoisonSymmetricKey(index int) error
- func (store *KeyStore) EnumerateExportedKeyPaths() ([]string, error)
- func (store *KeyStore) ExportKeyPair(key ExportedKey) (*keys.Keypair, error)
- func (store *KeyStore) ExportPlaintextSymmetricKey(key ExportedKey) ([]byte, error)
- func (store *KeyStore) ExportPrivateKey(key ExportedKey) (*keys.PrivateKey, error)
- func (store *KeyStore) ExportPublicKey(key ExportedKey) (*keys.PublicKey, error)
- func (store *KeyStore) ExportSymmetricKey(key ExportedKey) ([]byte, error)
- func (store *KeyStore) GenerateClientIDSymmetricKey(id []byte) error
- func (store *KeyStore) GenerateConnectorKeys(id []byte) error
- func (store *KeyStore) GenerateDataEncryptionKeys(id []byte) error
- func (store *KeyStore) GenerateHmacKey(id []byte) error
- func (store *KeyStore) GenerateLogKey() error
- func (store *KeyStore) GeneratePoisonKeyPair() error
- func (store *KeyStore) GeneratePoisonSymmetricKey() error
- func (store *KeyStore) GenerateServerKeys(id []byte) error
- func (store *KeyStore) GenerateTranslatorKeys(id []byte) error
- func (store *KeyStore) Get(keyID string) ([]byte, bool)
- func (store *KeyStore) GetClientIDEncryptionPublicKey(clientID []byte) (*keys.PublicKey, error)
- func (store *KeyStore) GetClientIDSymmetricKey(id []byte) ([]byte, error)
- func (store *KeyStore) GetClientIDSymmetricKeys(id []byte) ([][]byte, error)
- func (store *KeyStore) GetHMACSecretKey(id []byte) ([]byte, error)
- func (store *KeyStore) GetHistoricalPrivateKeyFilenames(filename string) ([]string, error)
- func (store *KeyStore) GetLogSecretKey() ([]byte, error)
- func (store *KeyStore) GetPeerPublicKey(id []byte) (*keys.PublicKey, error)
- func (store *KeyStore) GetPoisonKeyPair() (*keys.Keypair, error)
- func (store *KeyStore) GetPoisonPrivateKeys() ([]*keys.PrivateKey, error)
- func (store *KeyStore) GetPoisonSymmetricKey() ([]byte, error)
- func (store *KeyStore) GetPoisonSymmetricKeys() ([][]byte, error)
- func (store *KeyStore) GetPrivateKey(id []byte) (*keys.PrivateKey, error)
- func (store *KeyStore) GetPrivateKeyFilePath(filename string) string
- func (store *KeyStore) GetPublicKeyFilePath(filename string) string
- func (store *KeyStore) GetServerDecryptionPrivateKey(id []byte) (*keys.PrivateKey, error)
- func (store *KeyStore) GetServerDecryptionPrivateKeys(id []byte) ([]*keys.PrivateKey, error)
- func (store *KeyStore) ListKeys() ([]keystore.KeyDescription, error)
- func (store *KeyStore) ListRotatedKeys() ([]keystore.KeyDescription, error)
- func (store *KeyStore) ReadKeyFile(filename string) ([]byte, error)
- func (store *KeyStore) Reset()
- func (store *KeyStore) SaveDataEncryptionKeys(id []byte, keypair *keys.Keypair) error
- func (store *KeyStore) SaveKeyPairWithFilename(keypair *keys.Keypair, filename string, keyContext keystore.KeyContext) error
- func (store *KeyStore) WriteKeyFile(filename string, data []byte, mode os.FileMode) error
- func (store *KeyStore) WritePrivateKey(filename string, data []byte) error
- func (store *KeyStore) WritePublicKey(filename string, data []byte) error
- type KeyStoreBuilder
- func (b *KeyStoreBuilder) Build() (*KeyStore, error)
- func (b *KeyStoreBuilder) CacheSize(cacheSize int) *KeyStoreBuilder
- func (b *KeyStoreBuilder) Encryptor(encryptor keystore.KeyEncryptor) *KeyStoreBuilder
- func (b *KeyStoreBuilder) KeyDirectories(privateKeyDir, publicKeyDir string) *KeyStoreBuilder
- func (b *KeyStoreBuilder) KeyDirectory(directory string) *KeyStoreBuilder
- func (b *KeyStoreBuilder) Storage(storage Storage) *KeyStoreBuilder
- type RedisStorage
- func (r *RedisStorage) Copy(src, dst string) error
- func (r *RedisStorage) Exists(path string) (bool, error)
- func (r *RedisStorage) Link(oldpath, newpath string) error
- func (r *RedisStorage) MkdirAll(path string, perm os.FileMode) error
- func (r *RedisStorage) ReadDir(path string) ([]os.FileInfo, error)
- func (r *RedisStorage) ReadFile(path string) ([]byte, error)
- func (r *RedisStorage) Remove(path string) error
- func (r *RedisStorage) RemoveAll(path string) error
- func (r *RedisStorage) Rename(oldpath, newpath string) error
- func (r *RedisStorage) Stat(path string) (os.FileInfo, error)
- func (r *RedisStorage) TempDir(pattern string, perm os.FileMode) (string, error)
- func (r *RedisStorage) TempFile(pattern string, perm os.FileMode) (string, error)
- func (r *RedisStorage) WriteFile(path string, data []byte, perm os.FileMode) error
- type Storage
- type TranslatorFileSystemKeyStore
- func NewTranslatorFileSystemKeyStore(directory string, encryptor keystore.KeyEncryptor, cacheSize int) (*TranslatorFileSystemKeyStore, error)
- func NewTranslatorFileSystemKeyStoreFromServerStore(directory string, encryptor keystore.KeyEncryptor, store *KeyStore) (*TranslatorFileSystemKeyStore, error)
- type TranslatorFileSystemKeyStoreBuilder
- func (b *TranslatorFileSystemKeyStoreBuilder) Build() (*TranslatorFileSystemKeyStore, error)
- func (b *TranslatorFileSystemKeyStoreBuilder) Encryptor(encryptor keystore.KeyEncryptor) *TranslatorFileSystemKeyStoreBuilder
- func (b *TranslatorFileSystemKeyStoreBuilder) KeyDirectory(directory string) *TranslatorFileSystemKeyStoreBuilder
- func (b *TranslatorFileSystemKeyStoreBuilder) Storage(storage Storage) *TranslatorFileSystemKeyStoreBuilder
Constants ¶
const HistoricalFileNameTimeFormat = "2006-01-02T15:04:05.999999999"
HistoricalFileNameTimeFormat format used as filename for rotated keys
const (
PoisonKeyFilename = ".poison_key/poison_key"
)
Default key folders' filenames
const PrivateFileMode = os.FileMode(0600)
PrivateFileMode used for all created files with private data
const SecureLogKeyFilename = "secure_log_key"
SecureLogKeyFilename represent context for secure log key
Variables ¶
var ErrInvalidIndex = errors.New("invalid index value provided")
ErrInvalidIndex represent invalid key index for destroying
var ErrUnrecognizedKeyPurpose = errors.New("key purpose not recognized")
ErrUnrecognizedKeyPurpose describe key mismatch error
Functions ¶
func DescribeKeyFile ¶
func DescribeKeyFile(fileName string) (*keystore.KeyDescription, error)
DescribeKeyFile describes key by its purpose path for V1 and V2 keystore
func GetServerDecryptionKeyFilename ¶
GetServerDecryptionKeyFilename return filename for decryption key
func IsKeyDirectory ¶
func IsKeyDirectory(keyDirectory string, extractor *args.ServiceExtractor) bool
IsKeyDirectory checks if the local directory contains a keystore v1. This is a conservative check. That is, positive return value does not mean that the directory contains *a valid* keystore. However, false value means that the directory is definitely not a valid keystore. In particular, false is returned if the directory does not exists or cannot be opened.
func IsKeyReadError ¶
IsKeyReadError return true if error is os.ErrNotExist compatible and NoKeyFoundExit
Types ¶
type DefaultKeyFileClassifier ¶
type DefaultKeyFileClassifier struct{}
DefaultKeyFileClassifier is a KeyFileClassifier for standard key types.
func (*DefaultKeyFileClassifier) ClassifyExportedKey ¶
func (*DefaultKeyFileClassifier) ClassifyExportedKey(path string) *ExportedKey
ClassifyExportedKey tells how a key at given path should be exported.
type DummyStorage ¶
type DummyStorage struct{ FileStorage }
DummyStorage keeps key files in filesystem directories.
type ExportedKey ¶
type ExportedKey struct { PublicPath string PrivatePath string SymmetricPath string KeyContext keystore.KeyContext }
ExportedKey describes a key that can be exported from keystore.
`Purpose` describes the purpose of this key. This is one of the `Purpose...` constants exported by this module.
`ID` is either client ID or nil depending on the purpose.
`*Path` fields will be empty when not applicable. For example, symmetric keys will not have public or private parts, and only public or private key of a key pair may be present.
func EnumerateExportedKeys ¶
func EnumerateExportedKeys(enumerator KeyExportEnumerator) ([]ExportedKey, error)
EnumerateExportedKeys prepares a list of keys that can be exported. The keys are classified with default key file classifier.
func EnumerateExportedKeysByClass ¶
func EnumerateExportedKeysByClass(enumerator KeyExportEnumerator, classifier KeyFileClassifier) ([]ExportedKey, error)
EnumerateExportedKeysByClass prepares a list of keys that can be exported. The keys are classified with the provided classifier.
func NewExportedPlaintextSymmetricKey ¶
func NewExportedPlaintextSymmetricKey(symmetricPath string, keyContext keystore.KeyContext) *ExportedKey
NewExportedPlaintextSymmetricKey makes an ExportedKey for an unencrypted symmetric key file.
func NewExportedPrivateKey ¶
func NewExportedPrivateKey(privatePath string, keyContext keystore.KeyContext) *ExportedKey
NewExportedPrivateKey makes an ExportedKey for a private key file.
func NewExportedPublicKey ¶
func NewExportedPublicKey(publicPath string, keyContext keystore.KeyContext) *ExportedKey
NewExportedPublicKey makes an ExportedKey for a public key file.
func NewExportedSymmetricKey ¶
func NewExportedSymmetricKey(symmetricPath string, keyContext keystore.KeyContext) *ExportedKey
NewExportedSymmetricKey makes an ExportedKey for an unencrypted symmetric key file.
type FileStorage ¶
type FileStorage struct{}
FileStorage is implementation of Storage interface for filesystem
func (*FileStorage) Copy ¶
func (*FileStorage) Copy(src, dst string) error
Copy implementation of Storage interface
func (*FileStorage) Exists ¶
func (*FileStorage) Exists(path string) (bool, error)
Exists implementation of Storage interface
func (*FileStorage) Link ¶
func (*FileStorage) Link(oldpath, newpath string) error
Link implementation of Storage interface
func (*FileStorage) MkdirAll ¶
func (*FileStorage) MkdirAll(path string, perm os.FileMode) error
MkdirAll implementation of Storage interface
func (*FileStorage) ReadDir ¶
func (*FileStorage) ReadDir(path string) ([]os.FileInfo, error)
ReadDir implementation of Storage interface
func (*FileStorage) ReadFile ¶
func (*FileStorage) ReadFile(path string) ([]byte, error)
ReadFile implementation of Storage interface
func (*FileStorage) Remove ¶
func (*FileStorage) Remove(path string) error
Remove implementation of Storage interface
func (*FileStorage) RemoveAll ¶
func (*FileStorage) RemoveAll(path string) error
RemoveAll implementation of Storage interface
func (*FileStorage) Rename ¶
func (*FileStorage) Rename(oldpath, newpath string) error
Rename implementation of Storage interface
func (*FileStorage) Stat ¶
func (*FileStorage) Stat(path string) (os.FileInfo, error)
Stat implementation of Storage interface
type KeyBackuper ¶
type KeyBackuper struct {
// contains filtered or unexported fields
}
KeyBackuper export keys from KeyStore into encrypted bytes buffer
func NewKeyBackuper ¶
func NewKeyBackuper(privateFolder, publicFolder string, storage Storage, decryptor keystore.KeyEncryptor, keyStore keystore.ServerKeyStore) (*KeyBackuper, error)
NewKeyBackuper create, initialize and return new instance of KeyBackuper
func (*KeyBackuper) Export ¶
func (store *KeyBackuper) Export(exportIDs []keystore.ExportID, mode keystore.ExportMode) (*keystore.KeysBackup, error)
Export keys from KeyStore encrypted with new key for backup
func (*KeyBackuper) Import ¶
func (store *KeyBackuper) Import(backup *keystore.KeysBackup) ([]keystore.KeyDescription, error)
Import keys from backup to current keystore
type KeyExport ¶
type KeyExport interface { KeyExportEnumerator ExportPublicKey(key ExportedKey) (*keys.PublicKey, error) ExportPrivateKey(key ExportedKey) (*keys.PrivateKey, error) ExportKeyPair(key ExportedKey) (*keys.Keypair, error) ExportSymmetricKey(key ExportedKey) ([]byte, error) ExportPlaintextSymmetricKey(key ExportedKey) ([]byte, error) }
KeyExport allows to export plaintext key material by generic key description rather than specific purpose.
type KeyExportEnumerator ¶
KeyExportEnumerator provides a list of key paths to be exported.
type KeyFileClassifier ¶
type KeyFileClassifier interface {
ClassifyExportedKey(path string) *ExportedKey
}
KeyFileClassifier defines how to export keys stored in files. It divines the purpose of the key by its path. Return nil if the path should not be exported (e.g., if it's not a key).
type KeyStore ¶
type KeyStore struct {
// contains filtered or unexported fields
}
KeyStore represents keystore that reads keys from key folders, and stores them in memory.
func NewFileSystemKeyStoreWithCacheSize ¶
func NewFileSystemKeyStoreWithCacheSize(directory string, encryptor keystore.KeyEncryptor, cacheSize int) (*KeyStore, error)
NewFileSystemKeyStoreWithCacheSize represents keystore that reads keys from key folders, and stores them in cache.
func NewFilesystemKeyStore ¶
func NewFilesystemKeyStore(directory string, encryptor keystore.KeyEncryptor) (*KeyStore, error)
NewFilesystemKeyStore represents keystore that reads keys from key folders, and stores them in memory.
func NewFilesystemKeyStoreTwoPath ¶
func NewFilesystemKeyStoreTwoPath(privateKeyFolder, publicKeyFolder string, encryptor keystore.KeyEncryptor) (*KeyStore, error)
NewFilesystemKeyStoreTwoPath creates new KeyStore using separate folders for private and public keys.
func (*KeyStore) CacheOnStart ¶
CacheOnStart list and cache all keys from keystore
func (*KeyStore) DestroyClientIDEncryptionKeyPair ¶
DestroyClientIDEncryptionKeyPair destroy server encryption key pair
func (*KeyStore) DestroyClientIDSymmetricKey ¶
DestroyClientIDSymmetricKey destroy private poison key
func (*KeyStore) DestroyHmacSecretKey ¶
DestroyHmacSecretKey destroy hmac secter key
func (*KeyStore) DestroyPoisonKeyPair ¶
DestroyPoisonKeyPair destroy poison key pair
func (*KeyStore) DestroyPoisonSymmetricKey ¶
DestroyPoisonSymmetricKey destroy poison symmetric key
func (*KeyStore) DestroyRotatedClientIDEncryptionKeyPair ¶
DestroyRotatedClientIDEncryptionKeyPair destroy created rotated storage key pair
func (*KeyStore) DestroyRotatedClientIDSymmetricKey ¶
DestroyRotatedClientIDSymmetricKey destroy created rotated symmetric key
func (*KeyStore) DestroyRotatedHmacSecretKey ¶
DestroyRotatedHmacSecretKey destroy created rotated hmac symmetric key
func (*KeyStore) DestroyRotatedPoisonKeyPair ¶
DestroyRotatedPoisonKeyPair destroy poison rotated key pair by index
func (*KeyStore) DestroyRotatedPoisonSymmetricKey ¶
DestroyRotatedPoisonSymmetricKey destroy created rotated poison record symmetric key
func (*KeyStore) EnumerateExportedKeyPaths ¶
EnumerateExportedKeyPaths returns a list of key paths that can be exported from this keystore.
func (*KeyStore) ExportKeyPair ¶
func (store *KeyStore) ExportKeyPair(key ExportedKey) (*keys.Keypair, error)
ExportKeyPair loads a key pair for export.
func (*KeyStore) ExportPlaintextSymmetricKey ¶
func (store *KeyStore) ExportPlaintextSymmetricKey(key ExportedKey) ([]byte, error)
ExportPlaintextSymmetricKey loads an unencrypted symmetric key for export.
func (*KeyStore) ExportPrivateKey ¶
func (store *KeyStore) ExportPrivateKey(key ExportedKey) (*keys.PrivateKey, error)
ExportPrivateKey loads a private key for export.
func (*KeyStore) ExportPublicKey ¶
func (store *KeyStore) ExportPublicKey(key ExportedKey) (*keys.PublicKey, error)
ExportPublicKey loads a public key for export.
func (*KeyStore) ExportSymmetricKey ¶
func (store *KeyStore) ExportSymmetricKey(key ExportedKey) ([]byte, error)
ExportSymmetricKey loads a symmetric key for export.
func (*KeyStore) GenerateClientIDSymmetricKey ¶
GenerateClientIDSymmetricKey generate symmetric key for specified client id
func (*KeyStore) GenerateConnectorKeys ¶
GenerateConnectorKeys generates AcraConnector transport EC keypair using clientID as part of key name. Writes encrypted private key and plaintext public key to fs. Returns error if writing/encryption failed.
func (*KeyStore) GenerateDataEncryptionKeys ¶
GenerateDataEncryptionKeys generates Storage EC keypair for encrypting/decrypting data using clientID as part of key name. Writes encrypted private key and plaintext public key to fs. Returns error if writing/encryption failed.
func (*KeyStore) GenerateHmacKey ¶
GenerateHmacKey key for hmac calculation in in folder for private keys
func (*KeyStore) GenerateLogKey ¶
GenerateLogKey key for log integrity check calculation in folder for private keys
func (*KeyStore) GeneratePoisonKeyPair ¶
GeneratePoisonKeyPair generates new poison keypair, saving it in the storage. Old keypair is rotated.
func (*KeyStore) GeneratePoisonSymmetricKey ¶
GeneratePoisonSymmetricKey generate symmetric key for poison records
func (*KeyStore) GenerateServerKeys ¶
GenerateServerKeys generates AcraServer transport EC keypair using clientID as part of key name. Writes encrypted private key and plaintext public key to fs. Returns error if writing/encryption failed.
func (*KeyStore) GenerateTranslatorKeys ¶
GenerateTranslatorKeys generates AcraTranslator transport EC keypair using clientID as part of key name. Writes encrypted private key and plaintext public key to fs. Returns error if writing/encryption failed.
func (*KeyStore) GetClientIDEncryptionPublicKey ¶
GetClientIDEncryptionPublicKey return PublicKey by clientID from cache or load from main store
func (*KeyStore) GetClientIDSymmetricKey ¶
GetClientIDSymmetricKey return latest symmetric key for encryption by specified client id
func (*KeyStore) GetClientIDSymmetricKeys ¶
GetClientIDSymmetricKeys return symmetric keys for specified client id
func (*KeyStore) GetHMACSecretKey ¶
GetHMACSecretKey return key for hmac calculation according to id
func (*KeyStore) GetHistoricalPrivateKeyFilenames ¶
GetHistoricalPrivateKeyFilenames return filenames for current and rotated keys
func (*KeyStore) GetLogSecretKey ¶
GetLogSecretKey return key for log integrity checks
func (*KeyStore) GetPeerPublicKey ¶
GetPeerPublicKey returns public key for this clientID, gets it from cache or reads from fs.
func (*KeyStore) GetPoisonKeyPair ¶
GetPoisonKeyPair reads and returns poison EC keypair from the fs. Returns an error if fs or crypto operations fail. Also, returns ErrKeysNotFound if the key pair doesn't exist.
func (*KeyStore) GetPoisonPrivateKeys ¶
func (store *KeyStore) GetPoisonPrivateKeys() ([]*keys.PrivateKey, error)
GetPoisonPrivateKeys reads and returns poison EC private keys from the fs, returning them in order from newest to oldest. Returns an error if fs or crypto operations fail. Also, returns ErrKeysNotFound if the keys don't exist.
func (*KeyStore) GetPoisonSymmetricKey ¶
GetPoisonSymmetricKey reads and returns poison symmetric key from the fs. Returns an error if fs or crypto operations fail. Also, returns ErrKeysNotFound if the keys don't exist.
func (*KeyStore) GetPoisonSymmetricKeys ¶
GetPoisonSymmetricKeys reads and returns all poison symmetric keys from the fs, returning them in order from newest to oldest. Returns an error if fs or crypto operations fail. Also, returns ErrKeysNotFound if the keys don't exist.
func (*KeyStore) GetPrivateKey ¶
func (store *KeyStore) GetPrivateKey(id []byte) (*keys.PrivateKey, error)
GetPrivateKey reads encrypted client private key from fs, decrypts it with master key and clientID, and returns plaintext private key, or reading/decryption error.
func (*KeyStore) GetPrivateKeyFilePath ¶
GetPrivateKeyFilePath return path for file with private key with configured folder for store
func (*KeyStore) GetPublicKeyFilePath ¶
GetPublicKeyFilePath return path for file with public key with configured folder for store
func (*KeyStore) GetServerDecryptionPrivateKey ¶
func (store *KeyStore) GetServerDecryptionPrivateKey(id []byte) (*keys.PrivateKey, error)
GetServerDecryptionPrivateKey reads encrypted server storage private key from fs, decrypts it with master key and clientID, and returns plaintext private key, or reading/decryption error.
func (*KeyStore) GetServerDecryptionPrivateKeys ¶
func (store *KeyStore) GetServerDecryptionPrivateKeys(id []byte) ([]*keys.PrivateKey, error)
GetServerDecryptionPrivateKeys reads encrypted server storage private keys from fs, decrypts them with master key and clientID, and returns plaintext private keys, or reading/decryption error.
func (*KeyStore) ListKeys ¶
func (store *KeyStore) ListKeys() ([]keystore.KeyDescription, error)
ListKeys enumerates keys present in the keystore.
func (*KeyStore) ListRotatedKeys ¶
func (store *KeyStore) ListRotatedKeys() ([]keystore.KeyDescription, error)
ListRotatedKeys enumerates keys present in the keystore within old dir.
func (*KeyStore) ReadKeyFile ¶
ReadKeyFile reads raw key data for given filename.
func (*KeyStore) SaveDataEncryptionKeys ¶
SaveDataEncryptionKeys save or overwrite decryption keypair for client id
func (*KeyStore) SaveKeyPairWithFilename ¶
func (store *KeyStore) SaveKeyPairWithFilename(keypair *keys.Keypair, filename string, keyContext keystore.KeyContext) error
SaveKeyPairWithFilename save encrypted private key and public key to configured folders
func (*KeyStore) WriteKeyFile ¶
WriteKeyFile updates key data, creating a new file if necessary.
func (*KeyStore) WritePrivateKey ¶
WritePrivateKey writes private key from data to filename
type KeyStoreBuilder ¶
type KeyStoreBuilder struct {
// contains filtered or unexported fields
}
KeyStoreBuilder allows to build a custom keystore.
func NewCustomFilesystemKeyStore ¶
func NewCustomFilesystemKeyStore() *KeyStoreBuilder
NewCustomFilesystemKeyStore allows a custom-made KeyStore to be built. You must set at least root key directories and provide a KeyEncryptor.
func (*KeyStoreBuilder) Build ¶
func (b *KeyStoreBuilder) Build() (*KeyStore, error)
Build constructs a KeyStore with specified parameters.
func (*KeyStoreBuilder) CacheSize ¶
func (b *KeyStoreBuilder) CacheSize(cacheSize int) *KeyStoreBuilder
CacheSize sets cache size to use. By default cache size is unlimited,
func (*KeyStoreBuilder) Encryptor ¶
func (b *KeyStoreBuilder) Encryptor(encryptor keystore.KeyEncryptor) *KeyStoreBuilder
Encryptor sets cryptographic backend.
func (*KeyStoreBuilder) KeyDirectories ¶
func (b *KeyStoreBuilder) KeyDirectories(privateKeyDir, publicKeyDir string) *KeyStoreBuilder
KeyDirectories sets root key directories for private and public keys.
func (*KeyStoreBuilder) KeyDirectory ¶
func (b *KeyStoreBuilder) KeyDirectory(directory string) *KeyStoreBuilder
KeyDirectory sets root key directory. Private and public keys will be kept together.
func (*KeyStoreBuilder) Storage ¶
func (b *KeyStoreBuilder) Storage(storage Storage) *KeyStoreBuilder
Storage sets custom storage backend.
type RedisStorage ¶
type RedisStorage struct {
// contains filtered or unexported fields
}
RedisStorage provides a storage backend that keeps key in Redis.
type Storage ¶
type Storage interface { // Stat a file at given path. Stat(path string) (os.FileInfo, error) // Exists checks whether a file exists at a given path. Exists(path string) (bool, error) // ReadDir reads a directory and returns information about its contents sorted by filename. ReadDir(path string) ([]os.FileInfo, error) // MkdirAll creates directory at given path with given permissions, including all missing intermediate directories. // It is not at error if a directory already exists at this path. MkdirAll(path string, perm os.FileMode) error // Rename a file atomically from oldpath to newpath, replacing a file at newpath if it exists. Rename(oldpath, newpath string) error // TempFile creates a new temporary file with given name pattern and access permissions. // Name of the newly created file is returned. // Caller is responsible for removing the file once they are done with it. TempFile(pattern string, perm os.FileMode) (string, error) // TempDir creates a new temporary directory with given name pattern and access permissions. // Name of the newly created directory is returned. // Caller is responsible for removing the directory and its contents once they are done with it. TempDir(pattern string, perm os.FileMode) (string, error) // Link creates a hard link at newpath which refers to the same path as oldpath. // Not all file systems support hard links, and there may be restrictions on hard links between different directories. Link(oldpath, newpath string) error // Copy a file from src to dst, preserving access mode. // It is an error if dst already exists. // dst is an independent copy of src with initially identical content. Copy(src, dst string) error // ReadFile reads entire content of the specified file. ReadFile(path string) ([]byte, error) // WriteAll replaces entire content of the specified file, creating it with specified mode if it does not exist. WriteFile(path string, data []byte, perm os.FileMode) error // Remove the file or empty directory at given path. Remove(path string) error // RemoveAll removes the path with any children that it contains. RemoveAll(path string) error }
Storage interface provides support for alternative filesystem-like storage backends of KeyStore. Semantics of methods are identical to corresponding "os", "io", "io/ioutil" functions where applicable.
type TranslatorFileSystemKeyStore ¶
type TranslatorFileSystemKeyStore struct { *KeyStore // contains filtered or unexported fields }
TranslatorFileSystemKeyStore stores AcraTranslator keys configuration
func NewTranslatorFileSystemKeyStore ¶
func NewTranslatorFileSystemKeyStore(directory string, encryptor keystore.KeyEncryptor, cacheSize int) (*TranslatorFileSystemKeyStore, error)
NewTranslatorFileSystemKeyStore creates new TranslatorFileSystemKeyStore
func NewTranslatorFileSystemKeyStoreFromServerStore ¶
func NewTranslatorFileSystemKeyStoreFromServerStore(directory string, encryptor keystore.KeyEncryptor, store *KeyStore) (*TranslatorFileSystemKeyStore, error)
NewTranslatorFileSystemKeyStoreFromServerStore create TranslatorKeyStore which inherit KeyStore
func (*TranslatorFileSystemKeyStore) CheckIfPrivateKeyExists ¶
func (store *TranslatorFileSystemKeyStore) CheckIfPrivateKeyExists(id []byte) (bool, error)
CheckIfPrivateKeyExists checks if Keystore has Translator transport private key for establishing Secure Session connection, returns true if key exists in fs.
func (*TranslatorFileSystemKeyStore) GetPrivateKey ¶
func (store *TranslatorFileSystemKeyStore) GetPrivateKey(id []byte) (*keys.PrivateKey, error)
GetPrivateKey reads and decrypts Translator transport private key for establishing Secure Session connection.
type TranslatorFileSystemKeyStoreBuilder ¶
type TranslatorFileSystemKeyStoreBuilder struct {
// contains filtered or unexported fields
}
TranslatorFileSystemKeyStoreBuilder allows to build a custom keystore.
func NewCustomTranslatorFileSystemKeyStore ¶
func NewCustomTranslatorFileSystemKeyStore() *TranslatorFileSystemKeyStoreBuilder
NewCustomTranslatorFileSystemKeyStore allows to customize a translator keystore.
func (*TranslatorFileSystemKeyStoreBuilder) Build ¶
func (b *TranslatorFileSystemKeyStoreBuilder) Build() (*TranslatorFileSystemKeyStore, error)
Build a keystore.
func (*TranslatorFileSystemKeyStoreBuilder) Encryptor ¶
func (b *TranslatorFileSystemKeyStoreBuilder) Encryptor(encryptor keystore.KeyEncryptor) *TranslatorFileSystemKeyStoreBuilder
Encryptor sets key encryptor.
func (*TranslatorFileSystemKeyStoreBuilder) KeyDirectory ¶
func (b *TranslatorFileSystemKeyStoreBuilder) KeyDirectory(directory string) *TranslatorFileSystemKeyStoreBuilder
KeyDirectory sets key directory.
func (*TranslatorFileSystemKeyStoreBuilder) Storage ¶
func (b *TranslatorFileSystemKeyStoreBuilder) Storage(storage Storage) *TranslatorFileSystemKeyStoreBuilder
Storage sets custom storage.