diff options
author | Jakob Unterwurzacher | 2015-09-08 22:34:42 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2015-09-08 22:36:38 +0200 |
commit | 28cdff5889927fcf8d720f13fcfe139720906988 (patch) | |
tree | 1423404c1e9abc66e3bd73eb6af2457ada833615 /cryptfs/cryptfs_content.go | |
parent | b13cc9686c5497cf1e5971689d1112056ee10651 (diff) |
tests: add TestCiphertextRange
Diffstat (limited to 'cryptfs/cryptfs_content.go')
-rw-r--r-- | cryptfs/cryptfs_content.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cryptfs/cryptfs_content.go b/cryptfs/cryptfs_content.go index e23d9b5..b9dd61f 100644 --- a/cryptfs/cryptfs_content.go +++ b/cryptfs/cryptfs_content.go @@ -115,7 +115,7 @@ func (be *CryptFS) minu64(x uint64, y uint64) uint64 { // CiphertextRange - Get byte range in backing ciphertext corresponding // to plaintext range. Returns a range aligned to ciphertext blocks. -func (be *CryptFS) CiphertextRange(offset uint64, length uint64) (uint64, uint64, int) { +func (be *CryptFS) CiphertextRange(offset uint64, length uint64) (alignedOffset uint64, alignedLength uint64, skipBytes int) { // Decrypting the ciphertext will yield too many plaintext bytes. Skip this number // of bytes from the front. skip := offset % be.plainBS @@ -123,10 +123,11 @@ func (be *CryptFS) CiphertextRange(offset uint64, length uint64) (uint64, uint64 firstBlockNo := offset / be.plainBS lastBlockNo := ( offset + length - 1 ) / be.plainBS - alignedOffset := firstBlockNo * be.cipherBS - alignedLength := (lastBlockNo - firstBlockNo + 1) * be.cipherBS + alignedOffset = firstBlockNo * be.cipherBS + alignedLength = (lastBlockNo - firstBlockNo + 1) * be.cipherBS - return alignedOffset, alignedLength, int(skip) + skipBytes = int(skip) + return alignedOffset, alignedLength, skipBytes } // Get the byte range in the ciphertext corresponding to blocks |