summaryrefslogtreecommitdiff
path: root/cryptfs/content_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-09-08 22:34:42 +0200
committerJakob Unterwurzacher2015-09-08 22:36:38 +0200
commit28cdff5889927fcf8d720f13fcfe139720906988 (patch)
tree1423404c1e9abc66e3bd73eb6af2457ada833615 /cryptfs/content_test.go
parentb13cc9686c5497cf1e5971689d1112056ee10651 (diff)
tests: add TestCiphertextRange
Diffstat (limited to 'cryptfs/content_test.go')
-rw-r--r--cryptfs/content_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/cryptfs/content_test.go b/cryptfs/content_test.go
index 1900818..b53eeeb 100644
--- a/cryptfs/content_test.go
+++ b/cryptfs/content_test.go
@@ -32,3 +32,29 @@ func TestSplitRange(t *testing.T) {
}
}
}
+
+func TestCiphertextRange(t *testing.T) {
+ var ranges []testRange
+
+ ranges = append(ranges, testRange{0, 70000},
+ testRange{0, 10},
+ testRange{234, 6511},
+ testRange{65444, 54},
+ testRange{6654, 8945})
+
+ var key [16]byte
+ f := NewCryptFS(key, true)
+
+ for _, r := range(ranges) {
+ alignedOffset, alignedLength, skipBytes := f.CiphertextRange(r.offset, r.length)
+ if alignedLength < r.length {
+ t.Fail()
+ }
+ if alignedOffset % f.cipherBS != 0 {
+ t.Fail()
+ }
+ if r.offset % f.plainBS != 0 && skipBytes == 0 {
+ t.Fail()
+ }
+ }
+}