github.com/advanderveer/restic@v0.8.1-0.20171209104529-42a8c19aaea6/internal/restic/buffer.go (about)

     1  package restic
     2  
     3  import "github.com/restic/restic/internal/crypto"
     4  
     5  // NewBlobBuffer returns a buffer that is large enough to hold a blob of size
     6  // plaintext bytes, including the crypto overhead.
     7  func NewBlobBuffer(size int) []byte {
     8  	return make([]byte, size, size+crypto.Extension)
     9  }
    10  
    11  // PlaintextLength returns the plaintext length of a blob with ciphertextSize
    12  // bytes.
    13  func PlaintextLength(ciphertextSize int) int {
    14  	return ciphertextSize - crypto.Extension
    15  }
    16  
    17  // CiphertextLength returns the encrypted length of a blob with plaintextSize
    18  // bytes.
    19  func CiphertextLength(plaintextSize int) int {
    20  	return plaintextSize + crypto.Extension
    21  }