aboutsummaryrefslogtreecommitdiff
path: root/internal/nametransform
diff options
context:
space:
mode:
Diffstat (limited to 'internal/nametransform')
-rw-r--r--internal/nametransform/diriv.go (renamed from internal/nametransform/names_diriv.go)0
-rw-r--r--internal/nametransform/name_api.go18
-rw-r--r--internal/nametransform/names.go (renamed from internal/nametransform/names_core.go)27
-rw-r--r--internal/nametransform/noiv.go (renamed from internal/nametransform/names_noiv.go)0
4 files changed, 23 insertions, 22 deletions
diff --git a/internal/nametransform/names_diriv.go b/internal/nametransform/diriv.go
index b9473aa..b9473aa 100644
--- a/internal/nametransform/names_diriv.go
+++ b/internal/nametransform/diriv.go
diff --git a/internal/nametransform/name_api.go b/internal/nametransform/name_api.go
deleted file mode 100644
index 7ac7d26..0000000
--- a/internal/nametransform/name_api.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package nametransform
-
-import "github.com/rfjakob/gocryptfs/internal/cryptocore"
-
-type NameTransform struct {
- cryptoCore *cryptocore.CryptoCore
- useEME bool
- longNames bool
- DirIVCache dirIVCache
-}
-
-func New(c *cryptocore.CryptoCore, useEME bool, longNames bool) *NameTransform {
- return &NameTransform{
- cryptoCore: c,
- longNames: longNames,
- useEME: useEME,
- }
-}
diff --git a/internal/nametransform/names_core.go b/internal/nametransform/names.go
index 779b885..8a7e260 100644
--- a/internal/nametransform/names_core.go
+++ b/internal/nametransform/names.go
@@ -9,10 +9,28 @@ import (
"fmt"
"github.com/rfjakob/eme"
+
+ "github.com/rfjakob/gocryptfs/internal/cryptocore"
)
+type NameTransform struct {
+ cryptoCore *cryptocore.CryptoCore
+ useEME bool
+ longNames bool
+ DirIVCache dirIVCache
+}
+
+func New(c *cryptocore.CryptoCore, useEME bool, longNames bool) *NameTransform {
+ return &NameTransform{
+ cryptoCore: c,
+ longNames: longNames,
+ useEME: useEME,
+ }
+}
+
// DecryptName - decrypt base64-encoded encrypted filename "cipherName"
-// The used encryption is either CBC or EME, depending on "useEME".
+// Used by DecryptPathDirIV().
+// The encryption is either CBC or EME, depending on "useEME".
//
// This function is exported because it allows for a very efficient readdir
// implementation (read IV once, decrypt all names using this function).
@@ -43,11 +61,12 @@ func (n *NameTransform) DecryptName(cipherName string, iv []byte) (string, error
return plain, err
}
-// encryptName - encrypt "plainName", return base64-encoded "cipherName64"
-// The used encryption is either CBC or EME, depending on "useEME".
+// encryptName - encrypt "plainName", return base64-encoded "cipherName64".
+// Used internally by EncryptPathDirIV().
+// The encryption is either CBC or EME, depending on "useEME".
//
// This function is exported because fusefrontend needs access to the full (not hashed)
-// name if longname is used
+// name if longname is used. Otherwise you should use EncryptPathDirIV()
func (n *NameTransform) EncryptName(plainName string, iv []byte) (cipherName64 string) {
bin := []byte(plainName)
diff --git a/internal/nametransform/names_noiv.go b/internal/nametransform/noiv.go
index f1009e4..f1009e4 100644
--- a/internal/nametransform/names_noiv.go
+++ b/internal/nametransform/noiv.go