Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Encrypter ¶
type Encrypter struct {
// contains filtered or unexported fields
}
Encrypter is a struct responsible for encrypting and decrypting data.
func KeyRingEncrypter ¶
KeyRingEncrypter derives an encryption key to encrypt all our files that are written to disk and returns an Encrypter object holding the key.
The key itself, is the sha2 of a base key that we get from the keyring. We derive the key this way as we don't force the HSM (or any future abstractions) to be able to derive and know of the cipher that we'll use within our protocol.
func (Encrypter) DecryptPayloadFromReader ¶
DecryptPayloadFromReader attempts to decrypt the encrypted bytes within the passed io.Reader instance using the key derived from the passed keyRing. For further details regarding the key derivation protocol, see the KeyRingEncrypter function.
func (Encrypter) EncryptPayloadToWriter ¶
EncryptPayloadToWriter attempts to write the set of provided bytes into the passed io.Writer in an encrypted form. We use a 24-byte chachapoly AEAD instance with a randomized nonce that's pre-pended to the final payload and used as associated data in the AEAD.
type EncrypterDecrypter ¶
type EncrypterDecrypter interface { // EncryptPayloadToWriter attempts to write the set of provided bytes // into the passed io.Writer in an encrypted form. EncryptPayloadToWriter([]byte, io.Writer) error // DecryptPayloadFromReader attempts to decrypt the encrypted bytes // within the passed io.Reader instance using the key derived from // the passed keyRing. DecryptPayloadFromReader(io.Reader) ([]byte, error) }
EncrypterDecrypter is an interface representing an object that encrypts or decrypts data.
type MockKeyRing ¶
type MockKeyRing struct {
Fail bool
}
func (*MockKeyRing) DeriveKey ¶
func (m *MockKeyRing) DeriveKey( keyLoc keychain.KeyLocator) (keychain.KeyDescriptor, error)
func (*MockKeyRing) DeriveNextKey ¶
func (m *MockKeyRing) DeriveNextKey( keyFam keychain.KeyFamily) (keychain.KeyDescriptor, error)