2017-01-13 11:57:05 +00:00
|
|
|
package restic
|
|
|
|
|
2017-07-23 12:21:03 +00:00
|
|
|
import "github.com/restic/restic/internal/crypto"
|
2017-01-13 11:57:05 +00:00
|
|
|
|
|
|
|
// NewBlobBuffer returns a buffer that is large enough to hold a blob of size
|
|
|
|
// plaintext bytes, including the crypto overhead.
|
|
|
|
func NewBlobBuffer(size int) []byte {
|
|
|
|
return make([]byte, size, size+crypto.Extension)
|
|
|
|
}
|
|
|
|
|
|
|
|
// PlaintextLength returns the plaintext length of a blob with ciphertextSize
|
|
|
|
// bytes.
|
|
|
|
func PlaintextLength(ciphertextSize int) int {
|
|
|
|
return ciphertextSize - crypto.Extension
|
|
|
|
}
|
|
|
|
|
|
|
|
// CiphertextLength returns the encrypted length of a blob with plaintextSize
|
|
|
|
// bytes.
|
|
|
|
func CiphertextLength(plaintextSize int) int {
|
|
|
|
return plaintextSize + crypto.Extension
|
|
|
|
}
|