aboutsummaryrefslogtreecommitdiff
path: root/cryptfs/cryptfs.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-09-13 21:47:18 +0200
committerJakob Unterwurzacher2015-09-13 22:09:38 +0200
commit6f9e90c414c165ff76cd7546b9898b51660a2440 (patch)
treed6dc91c505bc41e14d61dc592a5b07c9698dfe35 /cryptfs/cryptfs.go
parent164739b65588bcad91425f38db1ae1aae5c15e56 (diff)
Encrypt key with scrypt-hashed password
Diffstat (limited to 'cryptfs/cryptfs.go')
-rw-r--r--cryptfs/cryptfs.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/cryptfs/cryptfs.go b/cryptfs/cryptfs.go
index 8927d74..6380a92 100644
--- a/cryptfs/cryptfs.go
+++ b/cryptfs/cryptfs.go
@@ -3,6 +3,7 @@ package cryptfs
// CryptFS is the crypto backend of GoCryptFS
import (
+ "fmt"
"crypto/cipher"
"crypto/aes"
)
@@ -21,16 +22,22 @@ type CryptFS struct {
cipherBS uint64
}
-func NewCryptFS(key [16]byte, useOpenssl bool) *CryptFS {
+func NewCryptFS(key []byte, useOpenssl bool) *CryptFS {
- b, err := aes.NewCipher(key[:])
+ if len(key) != KEY_LEN {
+ panic(fmt.Sprintf("Unsupported key length %d", len(key)))
+ }
+
+ b, err := aes.NewCipher(key)
if err != nil {
panic(err)
}
var gcm cipher.AEAD
if useOpenssl {
- gcm = opensslGCM{key}
+ var k16 [16]byte
+ copy(k16[:], key)
+ gcm = opensslGCM{k16}
} else {
gcm, err = cipher.NewGCM(b)
if err != nil {