aboutsummaryrefslogtreecommitdiff
path: root/internal/nametransform/names.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-03-05 13:58:24 +0100
committerJakob Unterwurzacher2017-03-05 13:58:24 +0100
commite032539e2c09cd4d1f007d33d7ef97b0fec689ed (patch)
tree0dddfa591a048c8494580cef954c365aa32eced0 /internal/nametransform/names.go
parentb2f154a9a908e6ec097de90c04ce45118adc76de (diff)
cryptocore: use eme v1.1 interface
Version 1.1 of the EME package (github.com/rfjakob/eme) added a more convenient interface. Use it. Note that you have to upgrade your EME package (go get -u)!
Diffstat (limited to 'internal/nametransform/names.go')
-rw-r--r--internal/nametransform/names.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/internal/nametransform/names.go b/internal/nametransform/names.go
index ddb5faa..feec017 100644
--- a/internal/nametransform/names.go
+++ b/internal/nametransform/names.go
@@ -8,13 +8,12 @@ import (
"github.com/rfjakob/eme"
- "github.com/rfjakob/gocryptfs/internal/cryptocore"
"github.com/rfjakob/gocryptfs/internal/tlog"
)
// NameTransform is used to transform filenames.
type NameTransform struct {
- cryptoCore *cryptocore.CryptoCore
+ emeCipher *eme.EMECipher
longNames bool
DirIVCache dirIVCache
// b64 = either base64.URLEncoding or base64.RawURLEncoding
@@ -22,15 +21,15 @@ type NameTransform struct {
}
// New returns a new NameTransform instance.
-func New(c *cryptocore.CryptoCore, longNames bool, raw64 bool) *NameTransform {
+func New(e *eme.EMECipher, longNames bool, raw64 bool) *NameTransform {
b64 := base64.URLEncoding
if raw64 {
b64 = getRaw64Encoding()
}
return &NameTransform{
- cryptoCore: c,
- longNames: longNames,
- b64: b64,
+ emeCipher: e,
+ longNames: longNames,
+ b64: b64,
}
}
@@ -47,7 +46,7 @@ func (n *NameTransform) DecryptName(cipherName string, iv []byte) (string, error
tlog.Debug.Printf("DecryptName %q: decoded length %d is not a multiple of 16", cipherName, len(bin))
return "", syscall.EINVAL
}
- bin = eme.Transform(n.cryptoCore.BlockCipher, iv, bin, eme.DirectionDecrypt)
+ bin = n.emeCipher.Decrypt(iv, bin)
bin, err = unPad16(bin)
if err != nil {
tlog.Debug.Printf("pad16 error detail: %v", err)
@@ -69,7 +68,7 @@ func (n *NameTransform) DecryptName(cipherName string, iv []byte) (string, error
func (n *NameTransform) EncryptName(plainName string, iv []byte) (cipherName64 string) {
bin := []byte(plainName)
bin = pad16(bin)
- bin = eme.Transform(n.cryptoCore.BlockCipher, iv, bin, eme.DirectionEncrypt)
+ bin = n.emeCipher.Encrypt(iv, bin)
cipherName64 = n.b64.EncodeToString(bin)
return cipherName64
}