summaryrefslogtreecommitdiff
path: root/internal/contentenc/content_api.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/contentenc/content_api.go')
-rw-r--r--internal/contentenc/content_api.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/contentenc/content_api.go b/internal/contentenc/content_api.go
new file mode 100644
index 0000000..1700d35
--- /dev/null
+++ b/internal/contentenc/content_api.go
@@ -0,0 +1,31 @@
+package contentenc
+
+import "github.com/rfjakob/gocryptfs/internal/cryptocore"
+
+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
+}