Documentation
¶
Index ¶
- Constants
- func DecryptOptions(ciphertext []byte, fileNum base.FileNum, keyManager *KeyManager) ([]byte, error)
- func EncryptOptions(serializedOpts []byte, fileNum base.DiskFileNum, keyManager *KeyManager) ([]byte, error)
- func GetCipher(key []byte) (cipher.AEAD, error)
- func TestEnableRandomKey()
- type ApprovedWriter
- type KeyManager
- type Writer
Constants ¶
const GCMTagSize = 16
GCMTagSize is the AES-GCM tag size.
const (
// SaltChainFilename is the name of the salt chain file.
SaltChainFilename = "SALTCHAIN"
)
Variables ¶
This section is empty.
Functions ¶
func DecryptOptions ¶
func DecryptOptions( ciphertext []byte, fileNum base.FileNum, keyManager *KeyManager, ) ([]byte, error)
DecryptOptions decrypts the contents of an OPTIONS file.
func EncryptOptions ¶
func EncryptOptions( serializedOpts []byte, fileNum base.DiskFileNum, keyManager *KeyManager, ) ([]byte, error)
EncryptOptions encrypts the contents of an OPTIONS file.
func TestEnableRandomKey ¶
func TestEnableRandomKey()
TestEnableRandomKey enables the use of a random key in case no key has been set. This reduces required changes to existing tests.
Types ¶
type ApprovedWriter ¶
ApprovedWriter wraps an edg.Writer and provides an io.Writer interface. Use this to pass an edg.Writer to functions that expect an io.Writer.
type KeyManager ¶
type KeyManager struct {
// contains filtered or unexported fields
}
KeyManager manages the encryption keys for database files.
Call Create(fileNum) to create a new key when writing a file. Call Get(fileNum) to get the key when reading a file.
Internally, KeyManager maps file numbers to unique salts. File keys are derived with hkdf(masterKey, salt). The salts are stored integrity-protected in the SALTCHAIN file. The file is an append-only chain of saltBlocks, linked by HMACs.
As the encrypted files are file-level integrity-protected, together with key management via the salt chain we achieve "snapshot integrity" for the entire database.
func NewKeyManager ¶
NewKeyManager creates a new KeyManager.