Files
kopia/repo/format/encryptorWrapper.go
Ricardo Pescuma Domenecci 47aaa2dc40 feat(cli): Added ECC related options to repository create cli command (#2308)
* Encryptor pipeline

* Added ECC related options to repository create cli command

* Fix for lint errors

* Fixing comments from the PR

* Fixed lint errors

* Changes requested in PR

* Created e2e test
2022-08-13 08:49:22 -07:00

42 lines
969 B
Go

package format
import (
"github.com/kopia/kopia/internal/gather"
"github.com/kopia/kopia/repo/encryption"
)
type encryptorWrapper struct {
impl encryption.Encryptor
next encryption.Encryptor
}
func (p *encryptorWrapper) Encrypt(plainText gather.Bytes, contentID []byte, output *gather.WriteBuffer) error {
var tmp gather.WriteBuffer
defer tmp.Close()
if err := p.impl.Encrypt(plainText, contentID, &tmp); err != nil {
//nolint:wrapcheck
return err
}
//nolint:wrapcheck
return p.next.Encrypt(tmp.Bytes(), contentID, output)
}
func (p *encryptorWrapper) Decrypt(cipherText gather.Bytes, contentID []byte, output *gather.WriteBuffer) error {
var tmp gather.WriteBuffer
defer tmp.Close()
if err := p.next.Decrypt(cipherText, contentID, &tmp); err != nil {
//nolint:wrapcheck
return err
}
//nolint:wrapcheck
return p.impl.Decrypt(tmp.Bytes(), contentID, output)
}
func (p *encryptorWrapper) Overhead() int {
panic("Should not be called")
}