aboutsummaryrefslogtreecommitdiff
path: root/cryptfs/cryptfs_content.go
diff options
context:
space:
mode:
Diffstat (limited to 'cryptfs/cryptfs_content.go')
-rw-r--r--cryptfs/cryptfs_content.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/cryptfs/cryptfs_content.go b/cryptfs/cryptfs_content.go
index 5350ec7..0494b69 100644
--- a/cryptfs/cryptfs_content.go
+++ b/cryptfs/cryptfs_content.go
@@ -115,6 +115,15 @@ func (be *CryptFS) PlainSize(size uint64) uint64 {
return size
}
+// CipherSize - calculate ciphertext size from plaintext size
+func (be *CryptFS) CipherSize(size uint64) uint64 {
+ overhead := be.cipherBS - be.plainBS
+ nBlocks := (size + be.plainBS - 1) / be.plainBS
+ size += nBlocks * overhead
+
+ return size
+}
+
func (be *CryptFS) minu64(x uint64, y uint64) uint64 {
if x < y {
return x