26 lines
676 B
Go
26 lines
676 B
Go
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) {
|
|
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)
|
|
}
|