From 0c80cca674931c9dbfc69c25df24d53abbdd63a9 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 5 Jun 2016 14:26:16 +0200 Subject: toggledlog: convert remaing naked fmt.Print* Several fatal errors were just printed to stdout, which meant they were invisible when running the test suite. Fix this by introducing toggledlog.Fatal and convert as follows: Fatal errors -> toggledlog.Fatal Warnings -> toggledlog.Warn Password prompts -> fmt.Fprintf --- internal/configfile/kdf.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'internal/configfile') diff --git a/internal/configfile/kdf.go b/internal/configfile/kdf.go index f1a7a40..e77a743 100644 --- a/internal/configfile/kdf.go +++ b/internal/configfile/kdf.go @@ -1,13 +1,14 @@ package configfile import ( - "fmt" + "log" "math" "os" "golang.org/x/crypto/scrypt" "github.com/rfjakob/gocryptfs/internal/cryptocore" + "github.com/rfjakob/gocryptfs/internal/toggledlog" ) const ( @@ -31,7 +32,7 @@ func NewScryptKdf(logN int) scryptKdf { s.N = 1 << ScryptDefaultLogN } else { if logN < 10 { - fmt.Println("Error: scryptn below 10 is too low to make sense. Aborting.") + toggledlog.Fatal.Println("Error: scryptn below 10 is too low to make sense. Aborting.") os.Exit(1) } s.N = 1 << uint32(logN) @@ -45,7 +46,7 @@ func NewScryptKdf(logN int) scryptKdf { func (s *scryptKdf) DeriveKey(pw string) []byte { k, err := scrypt.Key([]byte(pw), s.Salt, s.N, s.R, s.P, s.KeyLen) if err != nil { - panic(fmt.Sprintf("DeriveKey failed: %s", err.Error())) + log.Panicf("DeriveKey failed: %v", err) } return k } -- cgit v1.2.3