From e032539e2c09cd4d1f007d33d7ef97b0fec689ed Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 5 Mar 2017 13:58:24 +0100 Subject: 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)! --- internal/nametransform/names.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'internal/nametransform') 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 } -- cgit v1.2.3