summaryrefslogtreecommitdiff
path: root/pathfs_frontend/names.go
blob: bb73ff410858aeaf0b8199eab54a37e025ffd8e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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.args.DirIV {
		return fs.CryptFS.TranslatePathZeroIV(plainPath, cryptfs.OpEncrypt)
	}
	fs.dirIVLock.RLock()
	defer fs.dirIVLock.RUnlock()
	return fs.CryptFS.EncryptPathDirIV(plainPath, fs.args.Cipherdir)
}

func (fs *FS) decryptPath(cipherPath string) (string, error) {
	if !fs.args.DirIV {
		return fs.CryptFS.TranslatePathZeroIV(cipherPath, cryptfs.OpDecrypt)
	}
	fs.dirIVLock.RLock()
	defer fs.dirIVLock.RUnlock()
	return fs.CryptFS.DecryptPathDirIV(cipherPath, fs.args.Cipherdir)
}