diff options
Diffstat (limited to 'internal')
-rw-r--r-- | internal/configfile/config_test.go | 4 | ||||
-rw-r--r-- | internal/contentenc/content_api.go | 5 | ||||
-rw-r--r-- | internal/contentenc/content_test.go | 19 | ||||
-rw-r--r-- | internal/fusefrontend/fs.go | 4 | ||||
-rw-r--r-- | internal/nametransform/names_test.go | 14 |
5 files changed, 28 insertions, 18 deletions
diff --git a/internal/configfile/config_test.go b/internal/configfile/config_test.go index 6606d22..5468b80 100644 --- a/internal/configfile/config_test.go +++ b/internal/configfile/config_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" "time" + + "github.com/rfjakob/gocryptfs/internal/toggledlog" ) func TestLoadV1(t *testing.T) { @@ -33,7 +35,7 @@ func TestLoadV2(t *testing.T) { func TestLoadV2PwdError(t *testing.T) { if !testing.Verbose() { - Warn.Enabled = false + toggledlog.Warn.Enabled = false } _, _, err := LoadConfFile("config_test/v2.conf", "wrongpassword") if err == nil { diff --git a/internal/contentenc/content_api.go b/internal/contentenc/content_api.go index 1700d35..4c6aa00 100644 --- a/internal/contentenc/content_api.go +++ b/internal/contentenc/content_api.go @@ -2,6 +2,11 @@ package contentenc import "github.com/rfjakob/gocryptfs/internal/cryptocore" +const ( + // Default plaintext block size + DefaultBS = 4096 +) + type ContentEnc struct { // Cryptographic primitives cryptoCore *cryptocore.CryptoCore diff --git a/internal/contentenc/content_test.go b/internal/contentenc/content_test.go index 70ad58d..2272aa3 100644 --- a/internal/contentenc/content_test.go +++ b/internal/contentenc/content_test.go @@ -2,6 +2,8 @@ package contentenc import ( "testing" + + "github.com/rfjakob/gocryptfs/internal/cryptocore" ) type testRange struct { @@ -20,8 +22,9 @@ func TestSplitRange(t *testing.T) { testRange{0, 65536}, testRange{6654, 8945}) - key := make([]byte, KEY_LEN) - f := NewCryptFS(key, true, false, true) + key := make([]byte, cryptocore.KeyLen) + cc := cryptocore.New(key, false, true) + f := New(cc, DefaultBS) for _, r := range ranges { parts := f.ExplodePlainRange(r.offset, r.length) @@ -31,7 +34,7 @@ func TestSplitRange(t *testing.T) { t.Errorf("Duplicate block number %d", p.BlockNo) } lastBlockNo = p.BlockNo - if p.Length > DEFAULT_PLAINBS || p.Skip >= DEFAULT_PLAINBS { + if p.Length > DefaultBS || p.Skip >= DefaultBS { t.Errorf("Test fail: n=%d, length=%d, offset=%d\n", p.BlockNo, p.Length, p.Skip) } } @@ -47,8 +50,9 @@ func TestCiphertextRange(t *testing.T) { testRange{65444, 54}, testRange{6654, 8945}) - key := make([]byte, KEY_LEN) - f := NewCryptFS(key, true, false, true) + key := make([]byte, cryptocore.KeyLen) + cc := cryptocore.New(key, false, true) + f := New(cc, DefaultBS) for _, r := range ranges { @@ -69,8 +73,9 @@ func TestCiphertextRange(t *testing.T) { } func TestBlockNo(t *testing.T) { - key := make([]byte, KEY_LEN) - f := NewCryptFS(key, true, false, true) + key := make([]byte, cryptocore.KeyLen) + cc := cryptocore.New(key, false, true) + f := New(cc, DefaultBS) b := f.CipherOffToBlockNo(788) if b != 0 { diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go index 0331215..a2deee5 100644 --- a/internal/fusefrontend/fs.go +++ b/internal/fusefrontend/fs.go @@ -21,8 +21,6 @@ import ( "github.com/rfjakob/gocryptfs/internal/configfile" ) -const plainBS = 4096 - type FS struct { pathfs.FileSystem // loopbackFileSystem, see go-fuse/fuse/pathfs/loopback.go args Args // Stores configuration arguments @@ -40,7 +38,7 @@ type FS struct { func NewFS(args Args) *FS { cryptoCore := cryptocore.New(args.Masterkey, args.OpenSSL, args.GCMIV128) - contentEnc := contentenc.New(cryptoCore, plainBS) + contentEnc := contentenc.New(cryptoCore, contentenc.DefaultBS) nameTransform := nametransform.New(cryptoCore, args.EMENames) return &FS{ diff --git a/internal/nametransform/names_test.go b/internal/nametransform/names_test.go index 4a901be..fdb9f05 100644 --- a/internal/nametransform/names_test.go +++ b/internal/nametransform/names_test.go @@ -3,6 +3,8 @@ package nametransform import ( "bytes" "testing" + + "github.com/rfjakob/gocryptfs/internal/cryptocore" ) func TestEncryptPathNoIV(t *testing.T) { @@ -11,8 +13,9 @@ func TestEncryptPathNoIV(t *testing.T) { s = append(s, "foo12312312312312312313123123123") s = append(s, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890") - key := make([]byte, KEY_LEN) - fs := NewCryptFS(key, true, false, true) + key := make([]byte, cryptocore.KeyLen) + cc := cryptocore.New(key, false, true) + fs := New(cc, true) for _, n := range s { c := fs.EncryptPathNoIV(n) @@ -32,19 +35,16 @@ func TestPad16(t *testing.T) { s = append(s, []byte("12345678901234567")) s = append(s, []byte("12345678901234567abcdefg")) - key := make([]byte, KEY_LEN) - fs := NewCryptFS(key, true, false, true) - for i := range s { orig := s[i] - padded := fs.pad16(orig) + padded := pad16(orig) if len(padded) <= len(orig) { t.Errorf("Padded length not bigger than orig: %d", len(padded)) } if len(padded)%16 != 0 { t.Errorf("Length is not aligend: %d", len(padded)) } - unpadded, err := fs.unPad16(padded) + unpadded, err := unPad16(padded) if err != nil { t.Error("unPad16 returned error:", err) } |