summaryrefslogtreecommitdiff
path: root/cryptfs/config_file.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-11-29 18:52:58 +0100
committerJakob Unterwurzacher2015-11-29 18:53:40 +0100
commitbb116282b7db6a6400586d756c6dfdcc8f85fdab (patch)
treef06fe917002c004569c84097595a4c5b357a4407 /cryptfs/config_file.go
parent71bfa1f0fb540790f87faac600e4041052b4d217 (diff)
Add "-scryptn" option that sets the cost parameter for scryptv0.5-rc1
Use that option to speed up the automated tests by 7 seconds. Before: ok github.com/rfjakob/gocryptfs/integration_tests 26.667s After: ok github.com/rfjakob/gocryptfs/integration_tests 19.534s
Diffstat (limited to 'cryptfs/config_file.go')
-rw-r--r--cryptfs/config_file.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/cryptfs/config_file.go b/cryptfs/config_file.go
index a0ab218..be37c60 100644
--- a/cryptfs/config_file.go
+++ b/cryptfs/config_file.go
@@ -35,8 +35,9 @@ type ConfFile struct {
}
// CreateConfFile - create a new config with a random key encrypted with
-// "password" and write it to "filename"
-func CreateConfFile(filename string, password string, plaintextNames bool) error {
+// "password" and write it to "filename".
+// Uses scrypt with cost parameter logN.
+func CreateConfFile(filename string, password string, plaintextNames bool, logN int) error {
var cf ConfFile
cf.filename = filename
@@ -45,7 +46,7 @@ func CreateConfFile(filename string, password string, plaintextNames bool) error
// Encrypt it using the password
// This sets ScryptObject and EncryptedKey
- cf.EncryptKey(key, password)
+ cf.EncryptKey(key, password, logN)
// Set defaults
cf.Version = HEADER_CURRENT_VERSION
@@ -109,10 +110,12 @@ func LoadConfFile(filename string, password string) ([]byte, *ConfFile, error) {
}
// EncryptKey - encrypt "key" using an scrypt hash generated from "password"
-// and store it in cf.EncryptedKey
-func (cf *ConfFile) EncryptKey(key []byte, password string) {
+// and store it in cf.EncryptedKey.
+// Uses scrypt with cost parameter logN and stores the scrypt parameters in
+// cf.ScryptObject.
+func (cf *ConfFile) EncryptKey(key []byte, password string, logN int) {
// Generate derived key from password
- cf.ScryptObject = NewScryptKdf()
+ cf.ScryptObject = NewScryptKdf(logN)
scryptHash := cf.ScryptObject.DeriveKey(password)
// Lock master key using password-based key