aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/fusefrontend_reverse/ctlsock_interface.go3
-rw-r--r--internal/fusefrontend_reverse/reverse_longnames.go2
-rw-r--r--internal/fusefrontend_reverse/rfs.go2
-rw-r--r--internal/nametransform/diriv.go4
-rw-r--r--internal/nametransform/longnames.go5
5 files changed, 7 insertions, 9 deletions
diff --git a/internal/fusefrontend_reverse/ctlsock_interface.go b/internal/fusefrontend_reverse/ctlsock_interface.go
index 1f02fc1..4b3ffe6 100644
--- a/internal/fusefrontend_reverse/ctlsock_interface.go
+++ b/internal/fusefrontend_reverse/ctlsock_interface.go
@@ -6,7 +6,6 @@ import (
"syscall"
"github.com/rfjakob/gocryptfs/internal/ctlsock"
- "github.com/rfjakob/gocryptfs/internal/nametransform"
)
var _ ctlsock.Interface = &ReverseFS{} // Verify that interface is implemented.
@@ -24,7 +23,7 @@ func (rfs *ReverseFS) EncryptPath(plainPath string) (string, error) {
dirIV := derivePathIV(cipherPath, ivPurposeDirIV)
encryptedPart := rfs.nameTransform.EncryptName(part, dirIV)
if rfs.args.LongNames && len(encryptedPart) > syscall.NAME_MAX {
- encryptedPart = nametransform.HashLongName(encryptedPart)
+ encryptedPart = rfs.nameTransform.HashLongName(encryptedPart)
}
cipherPath = filepath.Join(cipherPath, encryptedPart)
}
diff --git a/internal/fusefrontend_reverse/reverse_longnames.go b/internal/fusefrontend_reverse/reverse_longnames.go
index 24335bd..1d19643 100644
--- a/internal/fusefrontend_reverse/reverse_longnames.go
+++ b/internal/fusefrontend_reverse/reverse_longnames.go
@@ -68,7 +68,7 @@ func (rfs *ReverseFS) findLongnameParent(dir string, dirIV []byte, longname stri
if len(cName) <= syscall.NAME_MAX {
log.Panic("logic error or wrong shortNameMax constant?")
}
- hName := nametransform.HashLongName(cName)
+ hName := rfs.nameTransform.HashLongName(cName)
longnameParentCache[hName] = plaintextName
if longname == hName {
hit = plaintextName
diff --git a/internal/fusefrontend_reverse/rfs.go b/internal/fusefrontend_reverse/rfs.go
index 1bcbe45..fab3027 100644
--- a/internal/fusefrontend_reverse/rfs.go
+++ b/internal/fusefrontend_reverse/rfs.go
@@ -319,7 +319,7 @@ func (rfs *ReverseFS) OpenDir(cipherPath string, context *fuse.Context) ([]fuse.
} else {
cName = rfs.nameTransform.EncryptName(entries[i].Name, dirIV)
if len(cName) > syscall.NAME_MAX {
- cName = nametransform.HashLongName(cName)
+ cName = rfs.nameTransform.HashLongName(cName)
dotNameFile := fuse.DirEntry{
Mode: syscall.S_IFREG | 0600,
Name: cName + nametransform.LongNameSuffix,
diff --git a/internal/nametransform/diriv.go b/internal/nametransform/diriv.go
index cd96cfb..e4670c8 100644
--- a/internal/nametransform/diriv.go
+++ b/internal/nametransform/diriv.go
@@ -97,7 +97,7 @@ func (be *NameTransform) EncryptPathDirIV(plainPath string, rootDir string) (cip
if iv != nil {
cBaseName := be.EncryptName(baseName, iv)
if be.longNames && len(cBaseName) > syscall.NAME_MAX {
- cBaseName = HashLongName(cBaseName)
+ cBaseName = be.HashLongName(cBaseName)
}
cipherPath = filepath.Join(cParentDir, cBaseName)
return cipherPath, nil
@@ -113,7 +113,7 @@ func (be *NameTransform) EncryptPathDirIV(plainPath string, rootDir string) (cip
}
encryptedName := be.EncryptName(plainName, iv)
if be.longNames && len(encryptedName) > syscall.NAME_MAX {
- encryptedName = HashLongName(encryptedName)
+ encryptedName = be.HashLongName(encryptedName)
}
encryptedNames = append(encryptedNames, encryptedName)
wd = filepath.Join(wd, encryptedName)
diff --git a/internal/nametransform/longnames.go b/internal/nametransform/longnames.go
index 71a4c16..f9ba848 100644
--- a/internal/nametransform/longnames.go
+++ b/internal/nametransform/longnames.go
@@ -2,7 +2,6 @@ package nametransform
import (
"crypto/sha256"
- "encoding/base64"
"io/ioutil"
"os"
"path/filepath"
@@ -24,9 +23,9 @@ const (
// HashLongName - take the hash of a long string "name" and return
// "gocryptfs.longname.[sha256]"
-func HashLongName(name string) string {
+func (n *NameTransform) HashLongName(name string) string {
hashBin := sha256.Sum256([]byte(name))
- hashBase64 := base64.URLEncoding.EncodeToString(hashBin[:])
+ hashBase64 := n.b64.EncodeToString(hashBin[:])
return longNamePrefix + hashBase64
}