From bb116282b7db6a6400586d756c6dfdcc8f85fdab Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 29 Nov 2015 18:52:58 +0100 Subject: Add "-scryptn" option that sets the cost parameter for scrypt 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 --- cryptfs/config_file.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'cryptfs/config_file.go') 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 -- cgit v1.2.3