aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/nametransform/names_test.go24
-rw-r--r--internal/nametransform/noiv.go63
2 files changed, 0 insertions, 87 deletions
diff --git a/internal/nametransform/names_test.go b/internal/nametransform/names_test.go
index f996860..d772af2 100644
--- a/internal/nametransform/names_test.go
+++ b/internal/nametransform/names_test.go
@@ -3,32 +3,8 @@ package nametransform
import (
"bytes"
"testing"
-
- "github.com/rfjakob/gocryptfs/internal/cryptocore"
)
-func TestEncryptPathNoIV(t *testing.T) {
- var s []string
- s = append(s, "foo")
- s = append(s, "foo12312312312312312313123123123")
- s = append(s, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890")
-
- key := make([]byte, cryptocore.KeyLen)
- cc := cryptocore.New(key, true, true)
- fs := New(cc, true, false)
-
- for _, n := range s {
- c := fs.EncryptPathNoIV(n)
- d, err := fs.DecryptPathNoIV(c)
- if err != nil {
- t.Errorf("Got error from DecryptPathNoIV: %s", err)
- }
- if d != n {
- t.Errorf("Content mismatch, n != d: n=%s c=%s d=%s", n, c, d)
- }
- }
-}
-
func TestPad16(t *testing.T) {
var s [][]byte
s = append(s, []byte("foo"))
diff --git a/internal/nametransform/noiv.go b/internal/nametransform/noiv.go
deleted file mode 100644
index f1009e4..0000000
--- a/internal/nametransform/noiv.go
+++ /dev/null
@@ -1,63 +0,0 @@
-package nametransform
-
-import (
- "strings"
-)
-
-const (
- OpEncrypt = iota
- OpDecrypt
-)
-
-// DecryptPathNoIV - decrypt path using CBC without any IV.
-// This function is deprecated by the the more secure DirIV variant and only retained
-// for compatability with old filesystems.
-func (be *NameTransform) DecryptPathNoIV(cipherPath string) (plainPath string, err error) {
- plainPath, err = be.translatePathNoIV(cipherPath, OpDecrypt)
- return plainPath, err
-}
-
-// EncryptPathNoIV - decrypt path using CBC without any IV.
-// This function is deprecated by the the more secure DirIV variant and only retained
-// for compatability with old filesystems.
-func (be *NameTransform) EncryptPathNoIV(plainPath string) (cipherPath string) {
- cipherPath, _ = be.translatePathNoIV(plainPath, OpEncrypt)
- return cipherPath
-}
-
-// translatePathZeroIV - encrypt or decrypt path using CBC with an all-zero IV.
-// Just splits the string on "/" and hands the parts to encryptName() / decryptName()
-func (be *NameTransform) translatePathNoIV(path string, op int) (string, error) {
- var err error
-
- // Empty string means root directory
- if path == "" {
- return path, err
- }
-
- zeroIV := make([]byte, dirIVLen)
-
- // Run operation on each path component
- var translatedParts []string
- parts := strings.Split(path, "/")
- for _, part := range parts {
- if part == "" {
- // This happens on "/foo/bar/" on the front and on the end.
- // Don't panic.
- translatedParts = append(translatedParts, "")
- continue
- }
- var newPart string
- if op == OpEncrypt {
- newPart = be.EncryptName(part, zeroIV)
- } else {
- newPart, err = be.DecryptName(part, zeroIV)
- if err != nil {
- return "", err
- }
- }
- translatedParts = append(translatedParts, newPart)
- }
-
- return strings.Join(translatedParts, "/"), err
-}