aboutsummaryrefslogtreecommitdiff
path: root/backend.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-09-03 18:22:18 +0200
committerJakob Unterwurzacher2015-09-03 18:22:18 +0200
commit4e93fdf820695c6afb38d525b5cf1dcc64080305 (patch)
tree035c25c5816ccef1608d0d56a8256b62dc5131b9 /backend.go
Port from go-fuse to bazil/fuse
Diffstat (limited to 'backend.go')
-rw-r--r--backend.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/backend.go b/backend.go
new file mode 100644
index 0000000..ad80b9a
--- /dev/null
+++ b/backend.go
@@ -0,0 +1,42 @@
+package gocryptfs
+
+import (
+ "crypto/cipher"
+ "crypto/aes"
+)
+
+const (
+ NONCE_LEN = 12
+ AUTH_TAG_LEN = 16
+ DEFAULT_PLAINBS = 4096
+
+ ENCRYPT = true
+ DECRYPT = false
+)
+
+type Backend struct {
+ blockCipher cipher.Block
+ gcm cipher.AEAD
+ plainBS int64
+ cipherBS int64
+}
+
+func New(key [16]byte) *Backend {
+
+ b, err := aes.NewCipher(key[:])
+ if err != nil {
+ panic(err)
+ }
+
+ g, err := cipher.NewGCM(b)
+ if err != nil {
+ panic(err)
+ }
+
+ return &Backend{
+ blockCipher: b,
+ gcm: g,
+ plainBS: DEFAULT_PLAINBS,
+ cipherBS: DEFAULT_PLAINBS + NONCE_LEN + AUTH_TAG_LEN,
+ }
+}