summaryrefslogtreecommitdiff
path: root/cryptfs/content_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-10-04 11:03:40 +0200
committerJakob Unterwurzacher2015-10-04 11:03:40 +0200
commit5229b8f5f5ef8d3e91fe2ab1f415131337161577 (patch)
treeb0dfbb015ef7ffacee9f275afb98c50d3ef5c4ec /cryptfs/content_test.go
parentfa887417708484eee03daf423a96d024960ed524 (diff)
Add BlockNoPlainOff() and BlockNoCipherOff() + test
Also, fix key, it is now []byte, not [16]byte
Diffstat (limited to 'cryptfs/content_test.go')
-rw-r--r--cryptfs/content_test.go26
1 files changed, 24 insertions, 2 deletions
diff --git a/cryptfs/content_test.go b/cryptfs/content_test.go
index b53eeeb..8fd33c6 100644
--- a/cryptfs/content_test.go
+++ b/cryptfs/content_test.go
@@ -19,7 +19,7 @@ func TestSplitRange(t *testing.T) {
testRange{65444, 54},
testRange{6654, 8945})
- var key [16]byte
+ key := make([]byte, 16)
f := NewCryptFS(key, true)
for _, r := range(ranges) {
@@ -42,7 +42,7 @@ func TestCiphertextRange(t *testing.T) {
testRange{65444, 54},
testRange{6654, 8945})
- var key [16]byte
+ key := make([]byte, 16)
f := NewCryptFS(key, true)
for _, r := range(ranges) {
@@ -58,3 +58,25 @@ func TestCiphertextRange(t *testing.T) {
}
}
}
+
+func TestBlockNo(t *testing.T) {
+ key := make([]byte, 16)
+ f := NewCryptFS(key, true)
+
+ b := f.BlockNoCipherOff(788)
+ if b != 0 {
+ t.Errorf("actual: %d", b)
+ }
+ b = f.BlockNoCipherOff(f.CipherBS())
+ if b != 1 {
+ t.Errorf("actual: %d", b)
+ }
+ b = f.BlockNoPlainOff(788)
+ if b != 0 {
+ t.Errorf("actual: %d", b)
+ }
+ b = f.BlockNoPlainOff(f.PlainBS())
+ if b != 1 {
+ t.Errorf("actual: %d", b)
+ }
+}