mirror of
https://github.com/kopia/kopia.git
synced 2026-05-19 12:14:45 -04:00
* 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
42 lines
969 B
Go
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")
|
|
}
|