2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 12:55:18 +00:00
restic/internal/crypto/buffer.go

20 lines
573 B
Go
Raw Normal View History

2022-06-12 12:48:30 +00:00
package crypto
// 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 {
2022-06-12 12:48:30 +00:00
return make([]byte, size, size+Extension)
}
// PlaintextLength returns the plaintext length of a blob with ciphertextSize
// bytes.
func PlaintextLength(ciphertextSize int) int {
2022-06-12 12:48:30 +00:00
return ciphertextSize - Extension
}
// CiphertextLength returns the encrypted length of a blob with plaintextSize
// bytes.
func CiphertextLength(plaintextSize int) int {
2022-06-12 12:48:30 +00:00
return plaintextSize + Extension
}