aboutsummaryrefslogtreecommitdiff
path: root/cryptfs/cryptfs.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-09-06 10:38:43 +0200
committerJakob Unterwurzacher2015-09-06 10:42:34 +0200
commit58d1e24b7c4eb69376dd0ec230c42ea9aeb70f2d (patch)
treeac99fc15a5ab2f34fc85ac13188ffa6e4dc11815 /cryptfs/cryptfs.go
parentad3a1a88994bbf54e95295d70f7424b67894da3e (diff)
Add OpenSSL support for file content encryption/decryption
This brings streaming read performance from 30MB/s to 81MB/s (similar improvement for writes)
Diffstat (limited to 'cryptfs/cryptfs.go')
-rw-r--r--cryptfs/cryptfs.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/cryptfs/cryptfs.go b/cryptfs/cryptfs.go
index 9ec511a..40a9024 100644
--- a/cryptfs/cryptfs.go
+++ b/cryptfs/cryptfs.go
@@ -20,21 +20,26 @@ type CryptFS struct {
cipherBS uint64
}
-func NewCryptFS(key [16]byte) *CryptFS {
+func NewCryptFS(key [16]byte, useOpenssl bool) *CryptFS {
b, err := aes.NewCipher(key[:])
if err != nil {
panic(err)
}
- g, err := cipher.NewGCM(b)
- if err != nil {
- panic(err)
+ var gcm cipher.AEAD
+ if useOpenssl {
+ gcm = opensslGCM{key}
+ } else {
+ gcm, err = cipher.NewGCM(b)
+ if err != nil {
+ panic(err)
+ }
}
return &CryptFS{
blockCipher: b,
- gcm: g,
+ gcm: gcm,
plainBS: DEFAULT_PLAINBS,
cipherBS: DEFAULT_PLAINBS + NONCE_LEN + AUTH_TAG_LEN,
}