aboutsummaryrefslogtreecommitdiff
path: root/internal/contentenc
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-06-16 19:02:47 +0200
committerJakob Unterwurzacher2016-06-16 19:02:47 +0200
commit7e92ebe16a7735b29e0fdc62d4b5d49ce0dc2b66 (patch)
treec38b46c98ec73ea6ee48b3e6ab9569f249200e81 /internal/contentenc
parent6c3f97399a01a2d8480b39978209099335efbf7d (diff)
Rename nametransform, contentenc source files
Let's have shorter names, and merge *_api.go into the "main" file. No code changes.
Diffstat (limited to 'internal/contentenc')
-rw-r--r--internal/contentenc/content.go33
-rw-r--r--internal/contentenc/content_api.go35
2 files changed, 33 insertions, 35 deletions
diff --git a/internal/contentenc/content.go b/internal/contentenc/content.go
index 5bac2a2..2298c5e 100644
--- a/internal/contentenc/content.go
+++ b/internal/contentenc/content.go
@@ -8,9 +8,42 @@ import (
"encoding/hex"
"errors"
+ "github.com/rfjakob/gocryptfs/internal/cryptocore"
"github.com/rfjakob/gocryptfs/internal/tlog"
)
+const (
+ // Default plaintext block size
+ DefaultBS = 4096
+)
+
+type ContentEnc struct {
+ // Cryptographic primitives
+ cryptoCore *cryptocore.CryptoCore
+ // Plaintext block size
+ plainBS uint64
+ // Ciphertext block size
+ cipherBS uint64
+ // All-zero block of size cipherBS, for fast compares
+ allZeroBlock []byte
+}
+
+func New(cc *cryptocore.CryptoCore, plainBS uint64) *ContentEnc {
+
+ cipherBS := plainBS + uint64(cc.IVLen) + cryptocore.AuthTagLen
+
+ return &ContentEnc{
+ cryptoCore: cc,
+ plainBS: plainBS,
+ cipherBS: cipherBS,
+ allZeroBlock: make([]byte, cipherBS),
+ }
+}
+
+func (be *ContentEnc) PlainBS() uint64 {
+ return be.plainBS
+}
+
// DecryptBlocks - Decrypt a number of blocks
func (be *ContentEnc) DecryptBlocks(ciphertext []byte, firstBlockNo uint64, fileId []byte) ([]byte, error) {
cBuf := bytes.NewBuffer(ciphertext)
diff --git a/internal/contentenc/content_api.go b/internal/contentenc/content_api.go
deleted file mode 100644
index cf482b6..0000000
--- a/internal/contentenc/content_api.go
+++ /dev/null
@@ -1,35 +0,0 @@
-package contentenc
-
-import "github.com/rfjakob/gocryptfs/internal/cryptocore"
-
-const (
- // Default plaintext block size
- DefaultBS = 4096
-)
-
-type ContentEnc struct {
- // Cryptographic primitives
- cryptoCore *cryptocore.CryptoCore
- // Plaintext block size
- plainBS uint64
- // Ciphertext block size
- cipherBS uint64
- // All-zero block of size cipherBS, for fast compares
- allZeroBlock []byte
-}
-
-func New(cc *cryptocore.CryptoCore, plainBS uint64) *ContentEnc {
-
- cipherBS := plainBS + uint64(cc.IVLen) + cryptocore.AuthTagLen
-
- return &ContentEnc{
- cryptoCore: cc,
- plainBS: plainBS,
- cipherBS: cipherBS,
- allZeroBlock: make([]byte, cipherBS),
- }
-}
-
-func (be *ContentEnc) PlainBS() uint64 {
- return be.plainBS
-}