summaryrefslogtreecommitdiff
path: root/internal/nametransform
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-03-05 22:59:25 +0100
committerJakob Unterwurzacher2017-03-05 22:59:25 +0100
commit445b5019e3f5a74409ca66c166cc1c3ccdd3dce7 (patch)
tree7cae90c96d8113dee657e50aa1f514138b99fa14 /internal/nametransform
parent5b54577d2ec553055c06e05841f626c10368c6b6 (diff)
nametransform: fix Raw64 not affecting symlink targets
The symlink functions incorrectly hardcoded the padded base64 variant.
Diffstat (limited to 'internal/nametransform')
-rw-r--r--internal/nametransform/longnames.go2
-rw-r--r--internal/nametransform/names.go11
2 files changed, 7 insertions, 6 deletions
diff --git a/internal/nametransform/longnames.go b/internal/nametransform/longnames.go
index f9ba848..54095a4 100644
--- a/internal/nametransform/longnames.go
+++ b/internal/nametransform/longnames.go
@@ -25,7 +25,7 @@ const (
// "gocryptfs.longname.[sha256]"
func (n *NameTransform) HashLongName(name string) string {
hashBin := sha256.Sum256([]byte(name))
- hashBase64 := n.b64.EncodeToString(hashBin[:])
+ hashBase64 := n.B64.EncodeToString(hashBin[:])
return longNamePrefix + hashBase64
}
diff --git a/internal/nametransform/names.go b/internal/nametransform/names.go
index 83724fb..71c8cd3 100644
--- a/internal/nametransform/names.go
+++ b/internal/nametransform/names.go
@@ -16,8 +16,9 @@ type NameTransform struct {
emeCipher *eme.EMECipher
longNames bool
DirIVCache dirIVCache
- // b64 = either base64.URLEncoding or base64.RawURLEncoding
- b64 *base64.Encoding
+ // B64 = either base64.URLEncoding or base64.RawURLEncoding, depeding
+ // on the Raw64 feature flag
+ B64 *base64.Encoding
}
// New returns a new NameTransform instance.
@@ -29,7 +30,7 @@ func New(e *eme.EMECipher, longNames bool, raw64 bool) *NameTransform {
return &NameTransform{
emeCipher: e,
longNames: longNames,
- b64: b64,
+ B64: b64,
}
}
@@ -38,7 +39,7 @@ func New(e *eme.EMECipher, longNames bool, raw64 bool) *NameTransform {
// This function is exported because it allows for a very efficient readdir
// implementation (read IV once, decrypt all names using this function).
func (n *NameTransform) DecryptName(cipherName string, iv []byte) (string, error) {
- bin, err := n.b64.DecodeString(cipherName)
+ bin, err := n.B64.DecodeString(cipherName)
if err != nil {
return "", err
}
@@ -69,6 +70,6 @@ func (n *NameTransform) EncryptName(plainName string, iv []byte) (cipherName64 s
bin := []byte(plainName)
bin = pad16(bin)
bin = n.emeCipher.Encrypt(iv, bin)
- cipherName64 = n.b64.EncodeToString(bin)
+ cipherName64 = n.B64.EncodeToString(bin)
return cipherName64
}