Run go fmt

This commit is contained in:
Jakob Unterwurzacher 2016-02-06 20:23:36 +01:00
parent b0ee5258b1
commit c74772bc8d
13 changed files with 37 additions and 39 deletions

View File

@ -6,8 +6,8 @@ import (
"io/ioutil" "io/ioutil"
"log" "log"
"github.com/rfjakob/gocryptfs/internal/cryptocore"
"github.com/rfjakob/gocryptfs/internal/contentenc" "github.com/rfjakob/gocryptfs/internal/contentenc"
"github.com/rfjakob/gocryptfs/internal/cryptocore"
"github.com/rfjakob/gocryptfs/internal/toggledlog" "github.com/rfjakob/gocryptfs/internal/toggledlog"
) )
import "os" import "os"

View File

@ -3,8 +3,8 @@ package contentenc
// File content encryption / decryption // File content encryption / decryption
import ( import (
"encoding/binary"
"bytes" "bytes"
"encoding/binary"
"encoding/hex" "encoding/hex"
"errors" "errors"

View File

@ -11,9 +11,9 @@ type ContentEnc struct {
// Cryptographic primitives // Cryptographic primitives
cryptoCore *cryptocore.CryptoCore cryptoCore *cryptocore.CryptoCore
// Plaintext block size // Plaintext block size
plainBS uint64 plainBS uint64
// Ciphertext block size // Ciphertext block size
cipherBS uint64 cipherBS uint64
// All-zero block of size cipherBS, for fast compares // All-zero block of size cipherBS, for fast compares
allZeroBlock []byte allZeroBlock []byte
} }
@ -23,14 +23,13 @@ func New(cc *cryptocore.CryptoCore, plainBS uint64) *ContentEnc {
cipherBS := plainBS + uint64(cc.IVLen) + cryptocore.AuthTagLen cipherBS := plainBS + uint64(cc.IVLen) + cryptocore.AuthTagLen
return &ContentEnc{ return &ContentEnc{
cryptoCore: cc, cryptoCore: cc,
plainBS: plainBS, plainBS: plainBS,
cipherBS: cipherBS, cipherBS: cipherBS,
allZeroBlock: make([]byte, cipherBS), allZeroBlock: make([]byte, cipherBS),
} }
} }
func (be *ContentEnc) PlainBS() uint64 { func (be *ContentEnc) PlainBS() uint64 {
return be.plainBS return be.plainBS
} }

View File

@ -15,9 +15,9 @@ const (
// Current On-Disk-Format version // Current On-Disk-Format version
CurrentVersion = 2 CurrentVersion = 2
HEADER_VERSION_LEN = 2 // uint16 HEADER_VERSION_LEN = 2 // uint16
HEADER_ID_LEN = 16 // 128 bit random file id HEADER_ID_LEN = 16 // 128 bit random file id
HEADER_LEN = HEADER_VERSION_LEN + HEADER_ID_LEN // Total header length HEADER_LEN = HEADER_VERSION_LEN + HEADER_ID_LEN // Total header length
) )
type FileHeader struct { type FileHeader struct {

View File

@ -1,21 +1,21 @@
package cryptocore package cryptocore
import ( import (
"crypto/cipher"
"crypto/aes" "crypto/aes"
"crypto/cipher"
"fmt" "fmt"
) )
const ( const (
KeyLen = 32 // AES-256 KeyLen = 32 // AES-256
AuthTagLen = 16 AuthTagLen = 16
) )
type CryptoCore struct { type CryptoCore struct {
BlockCipher cipher.Block BlockCipher cipher.Block
Gcm cipher.AEAD Gcm cipher.AEAD
GcmIVGen *nonceGenerator GcmIVGen *nonceGenerator
IVLen int IVLen int
} }
func New(key []byte, useOpenssl bool, GCMIV128 bool) *CryptoCore { func New(key []byte, useOpenssl bool, GCMIV128 bool) *CryptoCore {
@ -49,8 +49,8 @@ func New(key []byte, useOpenssl bool, GCMIV128 bool) *CryptoCore {
return &CryptoCore{ return &CryptoCore{
BlockCipher: blockCipher, BlockCipher: blockCipher,
Gcm: gcm, Gcm: gcm,
GcmIVGen: &nonceGenerator{nonceLen: IVLen}, GcmIVGen: &nonceGenerator{nonceLen: IVLen},
IVLen: IVLen, IVLen: IVLen,
} }
} }

View File

@ -49,10 +49,10 @@ func NewFile(fd *os.File, writeOnly bool, contentEnc *contentenc.ContentEnc) nod
wlock.register(st.Ino) wlock.register(st.Ino)
return &file{ return &file{
fd: fd, fd: fd,
writeOnly: writeOnly, writeOnly: writeOnly,
contentEnc: contentEnc, contentEnc: contentEnc,
ino: st.Ino, ino: st.Ino,
} }
} }

View File

@ -14,11 +14,11 @@ import (
"github.com/hanwen/go-fuse/fuse/nodefs" "github.com/hanwen/go-fuse/fuse/nodefs"
"github.com/hanwen/go-fuse/fuse/pathfs" "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/cryptocore"
"github.com/rfjakob/gocryptfs/internal/nametransform" "github.com/rfjakob/gocryptfs/internal/nametransform"
"github.com/rfjakob/gocryptfs/internal/contentenc" "github.com/rfjakob/gocryptfs/internal/toggledlog"
"github.com/rfjakob/gocryptfs/internal/configfile"
) )
type FS struct { type FS struct {
@ -42,10 +42,10 @@ func NewFS(args Args) *FS {
nameTransform := nametransform.New(cryptoCore, args.EMENames) nameTransform := nametransform.New(cryptoCore, args.EMENames)
return &FS{ return &FS{
FileSystem: pathfs.NewLoopbackFileSystem(args.Cipherdir), FileSystem: pathfs.NewLoopbackFileSystem(args.Cipherdir),
args: args, args: args,
nameTransform: nameTransform, nameTransform: nameTransform,
contentEnc: contentEnc, contentEnc: contentEnc,
} }
} }

View File

@ -10,9 +10,9 @@ import (
"github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse"
"github.com/rfjakob/gocryptfs/internal/toggledlog"
"github.com/rfjakob/gocryptfs/internal/cryptocore" "github.com/rfjakob/gocryptfs/internal/cryptocore"
"github.com/rfjakob/gocryptfs/internal/nametransform" "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) { func (fs *FS) Mkdir(relPath string, mode uint32, context *fuse.Context) (code fuse.Status) {

View File

@ -4,13 +4,13 @@ import "github.com/rfjakob/gocryptfs/internal/cryptocore"
type NameTransform struct { type NameTransform struct {
cryptoCore *cryptocore.CryptoCore cryptoCore *cryptocore.CryptoCore
useEME bool useEME bool
DirIVCache dirIVCache DirIVCache dirIVCache
} }
func New(c *cryptocore.CryptoCore, useEME bool) *NameTransform { func New(c *cryptocore.CryptoCore, useEME bool) *NameTransform {
return &NameTransform{ return &NameTransform{
cryptoCore: c, cryptoCore: c,
useEME: useEME, useEME: useEME,
} }
} }

View File

@ -60,4 +60,3 @@ func (n *NameTransform) encryptName(plainName string, iv []byte) (cipherName64 s
cipherName64 = base64.URLEncoding.EncodeToString(bin) cipherName64 = base64.URLEncoding.EncodeToString(bin)
return cipherName64 return cipherName64
} }

View File

@ -8,16 +8,16 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/rfjakob/gocryptfs/internal/toggledlog"
"github.com/rfjakob/gocryptfs/internal/cryptocore" "github.com/rfjakob/gocryptfs/internal/cryptocore"
"github.com/rfjakob/gocryptfs/internal/toggledlog"
) )
const ( const (
// identical to AES block size // identical to AES block size
dirIVLen = 16 dirIVLen = 16
// dirIV is stored in this file. Exported because we have to ignore this // dirIV is stored in this file. Exported because we have to ignore this
// name in directory listing. // name in directory listing.
DirIVFilename = "gocryptfs.diriv" DirIVFilename = "gocryptfs.diriv"
) )
// A simple one-entry DirIV cache // A simple one-entry DirIV cache

View File

@ -1,9 +1,9 @@
package nametransform package nametransform
import ( import (
"fmt"
"crypto/aes" "crypto/aes"
"errors" "errors"
"fmt"
) )
// pad16 - pad data to AES block size (=16 byte) using standard PKCS#7 padding // pad16 - pad data to AES block size (=16 byte) using standard PKCS#7 padding

View File

@ -20,12 +20,12 @@ import (
"github.com/hanwen/go-fuse/fuse/nodefs" "github.com/hanwen/go-fuse/fuse/nodefs"
"github.com/hanwen/go-fuse/fuse/pathfs" "github.com/hanwen/go-fuse/fuse/pathfs"
"github.com/rfjakob/gocryptfs/internal/fusefrontend"
"github.com/rfjakob/gocryptfs/internal/configfile" "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/contentenc"
"github.com/rfjakob/gocryptfs/internal/cryptocore" "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 ( const (