aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-08-11 18:42:30 +0200
committerJakob Unterwurzacher2017-08-11 19:02:26 +0200
commit0c520845f3623eff28f0277a52e3ccffd928f5c2 (patch)
tree82a3e0f8c55ae980d29e33b230954638229089c9 /internal/fusefrontend
parentf59479736bed49411bda3368f419d6605f1faa78 (diff)
main: purge masterkey from memory as soon as possible
Remove the "Masterkey" field from fusefrontend.Args because it should not be stored longer than neccessary. Instead pass the masterkey as a separate argument to the filesystem initializers. Then overwrite it with zeros immediately so we don't have to wait for garbage collection. Note that the crypto implementation still stores at least a masterkey-derived value, so this change makes it harder, but not impossible, to extract the encryption keys from memory. Suggested at https://github.com/rfjakob/gocryptfs/issues/137
Diffstat (limited to 'internal/fusefrontend')
-rw-r--r--internal/fusefrontend/args.go1
-rw-r--r--internal/fusefrontend/fs.go4
2 files changed, 2 insertions, 3 deletions
diff --git a/internal/fusefrontend/args.go b/internal/fusefrontend/args.go
index 37f4463..fc9de73 100644
--- a/internal/fusefrontend/args.go
+++ b/internal/fusefrontend/args.go
@@ -7,7 +7,6 @@ import (
// Args is a container for arguments that are passed from main() to fusefrontend
type Args struct {
- Masterkey []byte
// Cipherdir is the backing storage directory (absolute path).
// For reverse mode, Cipherdir actually contains *plaintext* files.
Cipherdir string
diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go
index 7a23710..3c442a5 100644
--- a/internal/fusefrontend/fs.go
+++ b/internal/fusefrontend/fs.go
@@ -42,8 +42,8 @@ type FS struct {
var _ pathfs.FileSystem = &FS{} // Verify that interface is implemented.
// NewFS returns a new encrypted FUSE overlay filesystem.
-func NewFS(args Args) *FS {
- cryptoCore := cryptocore.New(args.Masterkey, args.CryptoBackend, contentenc.DefaultIVBits, args.HKDF, args.ForceDecode)
+func NewFS(masterkey []byte, args Args) *FS {
+ cryptoCore := cryptocore.New(masterkey, args.CryptoBackend, contentenc.DefaultIVBits, args.HKDF, args.ForceDecode)
contentEnc := contentenc.New(cryptoCore, contentenc.DefaultBS, args.ForceDecode)
nameTransform := nametransform.New(cryptoCore.EMECipher, args.LongNames, args.Raw64)