aboutsummaryrefslogtreecommitdiff
path: root/internal/nametransform
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-03-05 22:25:41 +0100
committerJakob Unterwurzacher2017-03-05 22:25:41 +0100
commit5b54577d2ec553055c06e05841f626c10368c6b6 (patch)
tree9b1739d5b9ccc597186662f4b235c7c71af6c0a9 /internal/nametransform
parentd0bc7970f721cee607d993406d97d32e2c660abe (diff)
nametransform: fix Raw64 not affecting longnames
HashLongName() incorrectly hardcoded the call to base64.URLEncoding.
Diffstat (limited to 'internal/nametransform')
-rw-r--r--internal/nametransform/diriv.go4
-rw-r--r--internal/nametransform/longnames.go5
2 files changed, 4 insertions, 5 deletions
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
}