libgocryptfs/pathfs_frontend/names.go

26 lines
694 B
Go
Raw Normal View History

package pathfs_frontend
// This file forwards file encryption operations to cryptfs
import (
"github.com/rfjakob/gocryptfs/cryptfs"
)
func (fs *FS) encryptPath(plainPath string) (string, error) {
2015-11-28 16:52:57 +01:00
if !fs.args.DirIV {
return fs.CryptFS.TranslatePathZeroIV(plainPath, cryptfs.OpEncrypt)
}
fs.dirIVLock.RLock()
defer fs.dirIVLock.RUnlock()
2015-11-28 16:52:57 +01:00
return fs.CryptFS.EncryptPathDirIV(plainPath, fs.args.Cipherdir)
}
func (fs *FS) decryptPath(cipherPath string) (string, error) {
2015-11-28 16:52:57 +01:00
if !fs.args.DirIV {
return fs.CryptFS.TranslatePathZeroIV(cipherPath, cryptfs.OpDecrypt)
}
fs.dirIVLock.RLock()
defer fs.dirIVLock.RUnlock()
2015-11-28 16:52:57 +01:00
return fs.CryptFS.DecryptPathDirIV(cipherPath, fs.args.Cipherdir)
}