diff options
Diffstat (limited to 'internal/contentenc/intrablock.go')
-rw-r--r-- | internal/contentenc/intrablock.go | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/internal/contentenc/intrablock.go b/internal/contentenc/intrablock.go index 9a22ea2..632e76b 100644 --- a/internal/contentenc/intrablock.go +++ b/internal/contentenc/intrablock.go @@ -2,10 +2,19 @@ package contentenc // intraBlock identifies a part of a file block type intraBlock struct { - BlockNo uint64 // Block number in file - Skip uint64 // Offset into block plaintext - Length uint64 // Length of plaintext data in this block - fs *ContentEnc + // Block number in the file + BlockNo uint64 + // Offset into block payload + // In forwared mode: block plaintext + // In reverse mode: offset into block ciphertext. Takes the header into + // account. + Skip uint64 + // Length of payload data in this block + // In forwared mode: length of the plaintext + // In reverse mode: length of the ciphertext. Takes header and trailer into + // account. + Length uint64 + fs *ContentEnc } // isPartial - is the block partial? This means we have to do read-modify-write. @@ -47,3 +56,14 @@ func (ib *intraBlock) JointCiphertextRange(blocks []intraBlock) (offset uint64, return offset, length } + +// Plaintext range corresponding to the sum of all "blocks" (complete blocks) +func JointPlaintextRange(blocks []intraBlock) (offset uint64, length uint64) { + firstBlock := blocks[0] + lastBlock := blocks[len(blocks)-1] + + offset = firstBlock.BlockPlainOff() + length = lastBlock.BlockPlainOff() + lastBlock.fs.PlainBS() - offset + + return offset, length +} |