diff options
author | Jakob Unterwurzacher | 2015-09-30 22:36:53 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2015-09-30 22:36:53 +0200 |
commit | b835f83fd54944de0aa87a4e53073c1204450fda (patch) | |
tree | 475f3930eda5a15700648927a617f8278a08916e /cryptfs | |
parent | aea8d8d6e7e0f852643804641b27d8038991eff9 (diff) |
Implement Truncate() + Test
Diffstat (limited to 'cryptfs')
-rw-r--r-- | cryptfs/cryptfs_content.go | 9 |
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 |