diff options
-rw-r--r-- | internal/configfile/config_file.go | 2 | ||||
-rw-r--r-- | internal/contentenc/content.go | 2 | ||||
-rw-r--r-- | internal/contentenc/content_api.go | 11 | ||||
-rw-r--r-- | internal/contentenc/file_header.go | 6 | ||||
-rw-r--r-- | internal/cryptocore/crypto_api.go | 16 | ||||
-rw-r--r-- | internal/fusefrontend/file.go | 6 | ||||
-rw-r--r-- | internal/fusefrontend/fs.go | 12 | ||||
-rw-r--r-- | internal/fusefrontend/fs_dir.go | 2 | ||||
-rw-r--r-- | internal/nametransform/name_api.go | 4 | ||||
-rw-r--r-- | internal/nametransform/names_core.go | 1 | ||||
-rw-r--r-- | internal/nametransform/names_diriv.go | 6 | ||||
-rw-r--r-- | internal/nametransform/pad16.go | 2 | ||||
-rw-r--r-- | main.go | 6 |
13 files changed, 37 insertions, 39 deletions
diff --git a/internal/configfile/config_file.go b/internal/configfile/config_file.go index 0128acc..8c53a4b 100644 --- a/internal/configfile/config_file.go +++ b/internal/configfile/config_file.go @@ -6,8 +6,8 @@ import ( "io/ioutil" "log" - "github.com/rfjakob/gocryptfs/internal/cryptocore" "github.com/rfjakob/gocryptfs/internal/contentenc" + "github.com/rfjakob/gocryptfs/internal/cryptocore" "github.com/rfjakob/gocryptfs/internal/toggledlog" ) import "os" diff --git a/internal/contentenc/content.go b/internal/contentenc/content.go index 14135a2..dd6aa26 100644 --- a/internal/contentenc/content.go +++ b/internal/contentenc/content.go @@ -3,8 +3,8 @@ package contentenc // File content encryption / decryption import ( - "encoding/binary" "bytes" + "encoding/binary" "encoding/hex" "errors" diff --git a/internal/contentenc/content_api.go b/internal/contentenc/content_api.go index 4c6aa00..cf482b6 100644 --- a/internal/contentenc/content_api.go +++ b/internal/contentenc/content_api.go @@ -11,9 +11,9 @@ type ContentEnc struct { // Cryptographic primitives cryptoCore *cryptocore.CryptoCore // Plaintext block size - plainBS uint64 + plainBS uint64 // Ciphertext block size - cipherBS uint64 + cipherBS uint64 // All-zero block of size cipherBS, for fast compares allZeroBlock []byte } @@ -23,14 +23,13 @@ func New(cc *cryptocore.CryptoCore, plainBS uint64) *ContentEnc { cipherBS := plainBS + uint64(cc.IVLen) + cryptocore.AuthTagLen return &ContentEnc{ - cryptoCore: cc, - plainBS: plainBS, - cipherBS: cipherBS, + cryptoCore: cc, + plainBS: plainBS, + cipherBS: cipherBS, allZeroBlock: make([]byte, cipherBS), } } - func (be *ContentEnc) PlainBS() uint64 { return be.plainBS } diff --git a/internal/contentenc/file_header.go b/internal/contentenc/file_header.go index 8a9dd2c..1463773 100644 --- a/internal/contentenc/file_header.go +++ b/internal/contentenc/file_header.go @@ -15,9 +15,9 @@ const ( // Current On-Disk-Format version CurrentVersion = 2 - HEADER_VERSION_LEN = 2 // uint16 - HEADER_ID_LEN = 16 // 128 bit random file id - HEADER_LEN = HEADER_VERSION_LEN + HEADER_ID_LEN // Total header length + HEADER_VERSION_LEN = 2 // uint16 + HEADER_ID_LEN = 16 // 128 bit random file id + HEADER_LEN = HEADER_VERSION_LEN + HEADER_ID_LEN // Total header length ) type FileHeader struct { diff --git a/internal/cryptocore/crypto_api.go b/internal/cryptocore/crypto_api.go index c6b6869..0db9bbb 100644 --- a/internal/cryptocore/crypto_api.go +++ b/internal/cryptocore/crypto_api.go @@ -1,21 +1,21 @@ package cryptocore import ( - "crypto/cipher" "crypto/aes" + "crypto/cipher" "fmt" ) const ( - KeyLen = 32 // AES-256 - AuthTagLen = 16 + KeyLen = 32 // AES-256 + AuthTagLen = 16 ) type CryptoCore struct { BlockCipher cipher.Block Gcm cipher.AEAD - GcmIVGen *nonceGenerator - IVLen int + GcmIVGen *nonceGenerator + IVLen int } func New(key []byte, useOpenssl bool, GCMIV128 bool) *CryptoCore { @@ -49,8 +49,8 @@ func New(key []byte, useOpenssl bool, GCMIV128 bool) *CryptoCore { return &CryptoCore{ BlockCipher: blockCipher, - Gcm: gcm, - GcmIVGen: &nonceGenerator{nonceLen: IVLen}, - IVLen: IVLen, + Gcm: gcm, + GcmIVGen: &nonceGenerator{nonceLen: IVLen}, + IVLen: IVLen, } } diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go index 2e0b504..c93c384 100644 --- a/internal/fusefrontend/file.go +++ b/internal/fusefrontend/file.go @@ -49,10 +49,10 @@ func NewFile(fd *os.File, writeOnly bool, contentEnc *contentenc.ContentEnc) nod wlock.register(st.Ino) return &file{ - fd: fd, - writeOnly: writeOnly, + fd: fd, + writeOnly: writeOnly, contentEnc: contentEnc, - ino: st.Ino, + ino: st.Ino, } } diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go index a2deee5..007744c 100644 --- a/internal/fusefrontend/fs.go +++ b/internal/fusefrontend/fs.go @@ -14,11 +14,11 @@ import ( "github.com/hanwen/go-fuse/fuse/nodefs" "github.com/hanwen/go-fuse/fuse/pathfs" - "github.com/rfjakob/gocryptfs/internal/toggledlog" + "github.com/rfjakob/gocryptfs/internal/configfile" + "github.com/rfjakob/gocryptfs/internal/contentenc" "github.com/rfjakob/gocryptfs/internal/cryptocore" "github.com/rfjakob/gocryptfs/internal/nametransform" - "github.com/rfjakob/gocryptfs/internal/contentenc" - "github.com/rfjakob/gocryptfs/internal/configfile" + "github.com/rfjakob/gocryptfs/internal/toggledlog" ) type FS struct { @@ -42,10 +42,10 @@ func NewFS(args Args) *FS { nameTransform := nametransform.New(cryptoCore, args.EMENames) return &FS{ - FileSystem: pathfs.NewLoopbackFileSystem(args.Cipherdir), - args: args, + FileSystem: pathfs.NewLoopbackFileSystem(args.Cipherdir), + args: args, nameTransform: nameTransform, - contentEnc: contentEnc, + contentEnc: contentEnc, } } diff --git a/internal/fusefrontend/fs_dir.go b/internal/fusefrontend/fs_dir.go index 2b1e25d..aed501d 100644 --- a/internal/fusefrontend/fs_dir.go +++ b/internal/fusefrontend/fs_dir.go @@ -10,9 +10,9 @@ import ( "github.com/hanwen/go-fuse/fuse" - "github.com/rfjakob/gocryptfs/internal/toggledlog" "github.com/rfjakob/gocryptfs/internal/cryptocore" "github.com/rfjakob/gocryptfs/internal/nametransform" + "github.com/rfjakob/gocryptfs/internal/toggledlog" ) func (fs *FS) Mkdir(relPath string, mode uint32, context *fuse.Context) (code fuse.Status) { diff --git a/internal/nametransform/name_api.go b/internal/nametransform/name_api.go index 462e99c..fe68e09 100644 --- a/internal/nametransform/name_api.go +++ b/internal/nametransform/name_api.go @@ -4,13 +4,13 @@ import "github.com/rfjakob/gocryptfs/internal/cryptocore" type NameTransform struct { cryptoCore *cryptocore.CryptoCore - useEME bool + useEME bool DirIVCache dirIVCache } func New(c *cryptocore.CryptoCore, useEME bool) *NameTransform { return &NameTransform{ cryptoCore: c, - useEME: useEME, + useEME: useEME, } } diff --git a/internal/nametransform/names_core.go b/internal/nametransform/names_core.go index 452ab45..2eb0026 100644 --- a/internal/nametransform/names_core.go +++ b/internal/nametransform/names_core.go @@ -60,4 +60,3 @@ func (n *NameTransform) encryptName(plainName string, iv []byte) (cipherName64 s cipherName64 = base64.URLEncoding.EncodeToString(bin) return cipherName64 } - diff --git a/internal/nametransform/names_diriv.go b/internal/nametransform/names_diriv.go index d31a066..61e5bf0 100644 --- a/internal/nametransform/names_diriv.go +++ b/internal/nametransform/names_diriv.go @@ -8,16 +8,16 @@ import ( "strings" "sync" - "github.com/rfjakob/gocryptfs/internal/toggledlog" "github.com/rfjakob/gocryptfs/internal/cryptocore" + "github.com/rfjakob/gocryptfs/internal/toggledlog" ) const ( // identical to AES block size - dirIVLen = 16 + dirIVLen = 16 // dirIV is stored in this file. Exported because we have to ignore this // name in directory listing. - DirIVFilename = "gocryptfs.diriv" + DirIVFilename = "gocryptfs.diriv" ) // A simple one-entry DirIV cache diff --git a/internal/nametransform/pad16.go b/internal/nametransform/pad16.go index c15160e..e512828 100644 --- a/internal/nametransform/pad16.go +++ b/internal/nametransform/pad16.go @@ -1,9 +1,9 @@ package nametransform import ( - "fmt" "crypto/aes" "errors" + "fmt" ) // pad16 - pad data to AES block size (=16 byte) using standard PKCS#7 padding @@ -20,12 +20,12 @@ import ( "github.com/hanwen/go-fuse/fuse/nodefs" "github.com/hanwen/go-fuse/fuse/pathfs" - "github.com/rfjakob/gocryptfs/internal/fusefrontend" "github.com/rfjakob/gocryptfs/internal/configfile" - "github.com/rfjakob/gocryptfs/internal/toggledlog" - "github.com/rfjakob/gocryptfs/internal/nametransform" "github.com/rfjakob/gocryptfs/internal/contentenc" "github.com/rfjakob/gocryptfs/internal/cryptocore" + "github.com/rfjakob/gocryptfs/internal/fusefrontend" + "github.com/rfjakob/gocryptfs/internal/nametransform" + "github.com/rfjakob/gocryptfs/internal/toggledlog" ) const ( |