2022-06-12 12:48:30 +00:00
|
|
|
package 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 {
|
2022-06-12 12:48:30 +00:00
|
|
|
return make([]byte, size, size+Extension)
|
2017-01-13 11:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
2017-01-13 11:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
2017-01-13 11:57:05 +00:00
|
|
|
}
|