From fe7355f9ee4ae8e52a9b76202e90032d78824f21 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Fri, 27 Nov 2015 23:34:55 +0100 Subject: diriv: use "DirIV" flag to discern and support mounting old filesystems --- pathfs_frontend/names.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'pathfs_frontend/names.go') diff --git a/pathfs_frontend/names.go b/pathfs_frontend/names.go index 9c6e010..122b3dd 100644 --- a/pathfs_frontend/names.go +++ b/pathfs_frontend/names.go @@ -1,14 +1,24 @@ package pathfs_frontend -// This file handles filename encryption +// This file forwards file encryption operations to cryptfs + +import ( + "github.com/rfjakob/gocryptfs/cryptfs" +) func (fs *FS) encryptPath(plainPath string) (string, error) { + if !fs.dirIV { + return fs.CryptFS.TranslatePathZeroIV(plainPath, cryptfs.OpEncrypt) + } fs.dirIVLock.RLock() defer fs.dirIVLock.RUnlock() return fs.CryptFS.EncryptPathDirIV(plainPath, fs.backingDir) } func (fs *FS) decryptPath(cipherPath string) (string, error) { + if !fs.dirIV { + return fs.CryptFS.TranslatePathZeroIV(cipherPath, cryptfs.OpDecrypt) + } fs.dirIVLock.RLock() defer fs.dirIVLock.RUnlock() return fs.CryptFS.DecryptPathDirIV(cipherPath, fs.backingDir) -- cgit v1.2.3