Run go fmt
This commit is contained in:
parent
5bd08abf40
commit
89fef80d32
@ -1,8 +1,8 @@
|
||||
package cryptfs
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
)
|
||||
import "os"
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cryptfs
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type testRange struct {
|
||||
@ -22,9 +22,9 @@ func TestSplitRange(t *testing.T) {
|
||||
key := make([]byte, 16)
|
||||
f := NewCryptFS(key, true)
|
||||
|
||||
for _, r := range(ranges) {
|
||||
for _, r := range ranges {
|
||||
parts := f.SplitRange(r.offset, r.length)
|
||||
for _, p := range(parts) {
|
||||
for _, p := range parts {
|
||||
if p.Length > DEFAULT_PLAINBS || p.Skip >= DEFAULT_PLAINBS {
|
||||
fmt.Printf("Test fail: n=%d, length=%d, offset=%d\n", p.BlockNo, p.Length, p.Skip)
|
||||
t.Fail()
|
||||
@ -45,7 +45,7 @@ func TestCiphertextRange(t *testing.T) {
|
||||
key := make([]byte, 16)
|
||||
f := NewCryptFS(key, true)
|
||||
|
||||
for _, r := range(ranges) {
|
||||
for _, r := range ranges {
|
||||
alignedOffset, alignedLength, skipBytes := f.CiphertextRange(r.offset, r.length)
|
||||
if alignedLength < r.length {
|
||||
t.Fail()
|
||||
|
@ -3,9 +3,9 @@ package cryptfs
|
||||
// CryptFS is the crypto backend of GoCryptFS
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"crypto/cipher"
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -4,11 +4,11 @@ package cryptfs
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"errors"
|
||||
"crypto/cipher"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"os"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -3,12 +3,12 @@ package cryptfs
|
||||
// Filename encryption / decryption function
|
||||
|
||||
import (
|
||||
"crypto/cipher"
|
||||
"crypto/aes"
|
||||
"fmt"
|
||||
"strings"
|
||||
"crypto/cipher"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cryptfs
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"bytes"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTranslatePath(t *testing.T) {
|
||||
@ -14,7 +14,7 @@ func TestTranslatePath(t *testing.T) {
|
||||
key := make([]byte, 16)
|
||||
fs := NewCryptFS(key, true)
|
||||
|
||||
for _, n := range(s) {
|
||||
for _, n := range s {
|
||||
c := fs.EncryptPath(n)
|
||||
d, err := fs.DecryptPath(c)
|
||||
if err != nil {
|
||||
@ -36,7 +36,7 @@ func TestPad16(t *testing.T) {
|
||||
key := make([]byte, 16)
|
||||
fs := NewCryptFS(key, true)
|
||||
|
||||
for i := range(s) {
|
||||
for i := range s {
|
||||
orig := s[i]
|
||||
padded := fs.pad16(orig)
|
||||
if len(padded) <= len(orig) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package cryptfs
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"sync"
|
||||
"crypto/rand"
|
||||
)
|
||||
|
||||
type nonce96 struct {
|
||||
|
10
main.go
10
main.go
@ -1,18 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"runtime/pprof"
|
||||
"io/ioutil"
|
||||
"encoding/hex"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
"encoding/hex"
|
||||
"runtime"
|
||||
"runtime/pprof"
|
||||
"time"
|
||||
|
||||
"github.com/rfjakob/gocryptfs/pathfs_frontend"
|
||||
"github.com/rfjakob/gocryptfs/cryptfs"
|
||||
"github.com/rfjakob/gocryptfs/pathfs_frontend"
|
||||
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
|
||||
|
@ -7,10 +7,10 @@ package benchmark
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
"github.com/spacemonkeygo/openssl"
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"github.com/spacemonkeygo/openssl"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func BenchmarkAESGCMSeal4K(b *testing.B) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package pathfs_frontend
|
||||
|
||||
import (
|
||||
"io"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"sync"
|
||||
"syscall"
|
||||
@ -139,7 +139,7 @@ func (f *file) doWrite(data []byte, off int64) (uint32, fuse.Status) {
|
||||
status := fuse.OK
|
||||
dataBuf := bytes.NewBuffer(data)
|
||||
blocks := f.cfs.SplitRange(uint64(off), uint64(len(data)))
|
||||
for _, b := range(blocks) {
|
||||
for _, b := range blocks {
|
||||
|
||||
blockData := dataBuf.Next(int(b.Length))
|
||||
|
||||
@ -180,7 +180,7 @@ func (f *file) doWrite(data []byte, off int64) (uint32, fuse.Status) {
|
||||
|
||||
// Write - FUSE call
|
||||
func (f *file) Write(data []byte, off int64) (uint32, fuse.Status) {
|
||||
cryptfs.Debug.Printf("ino%d: FUSE Write %s: offset=%d length=%d\n", f.ino, off, len(data))
|
||||
cryptfs.Debug.Printf("ino%d: FUSE Write: offset=%d length=%d\n", f.ino, off, len(data))
|
||||
|
||||
fi, err := f.fd.Stat()
|
||||
if err != nil {
|
||||
@ -249,7 +249,7 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
|
||||
// File grows
|
||||
if newSize > oldSize {
|
||||
blocks := f.cfs.SplitRange(oldSize, newSize-oldSize)
|
||||
for _, b := range(blocks) {
|
||||
for _, b := range blocks {
|
||||
// First and last block may be partial
|
||||
if b.IsPartial() {
|
||||
off, _ := b.PlaintextRange()
|
||||
|
@ -1,10 +1,10 @@
|
||||
package pathfs_frontend
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
"fmt"
|
||||
|
||||
"github.com/hanwen/go-fuse/fuse"
|
||||
"github.com/hanwen/go-fuse/fuse/nodefs"
|
||||
@ -24,7 +24,6 @@ func NewFS(key []byte, backing string, useOpenssl bool) *FS {
|
||||
CryptFS: cryptfs.NewCryptFS(key, useOpenssl),
|
||||
FileSystem: pathfs.NewLoopbackFileSystem(backing),
|
||||
backing: backing,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +51,7 @@ func (fs *FS) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Stat
|
||||
|
||||
func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, fuse.Status) {
|
||||
cryptfs.Debug.Printf("OpenDir(%s)\n", dirName)
|
||||
cipherEntries, status := fs.FileSystem.OpenDir(fs.EncryptPath(dirName), context);
|
||||
cipherEntries, status := fs.FileSystem.OpenDir(fs.EncryptPath(dirName), context)
|
||||
var plain []fuse.DirEntry
|
||||
if cipherEntries != nil {
|
||||
for i := range cipherEntries {
|
||||
|
Loading…
Reference in New Issue
Block a user