From d5adde1eeb13ba377f7c05b9f21893c01f61ec16 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 7 May 2017 22:15:01 +0200 Subject: exitcodes: pull all exit code definitions into the package This commit defines all exit codes in one place in the exitcodes package. Also, it adds a test to verify the exit code on incorrect password, which is what SiriKali cares about the most. Fixes https://github.com/rfjakob/gocryptfs/issues/77 . --- internal/configfile/scrypt.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'internal/configfile/scrypt.go') diff --git a/internal/configfile/scrypt.go b/internal/configfile/scrypt.go index 0646754..b5a3edb 100644 --- a/internal/configfile/scrypt.go +++ b/internal/configfile/scrypt.go @@ -8,6 +8,7 @@ import ( "golang.org/x/crypto/scrypt" "github.com/rfjakob/gocryptfs/internal/cryptocore" + "github.com/rfjakob/gocryptfs/internal/exitcodes" "github.com/rfjakob/gocryptfs/internal/tlog" ) @@ -84,22 +85,22 @@ func (s *ScryptKDF) validateParams() { minN := 1 << scryptMinLogN if s.N < minN { tlog.Fatal.Println("Fatal: scryptn below 10 is too low to make sense") - os.Exit(1) + os.Exit(exitcodes.ScryptParams) } if s.R < scryptMinR { tlog.Fatal.Printf("Fatal: scrypt parameter R below minimum: value=%d, min=%d", s.R, scryptMinR) - os.Exit(1) + os.Exit(exitcodes.ScryptParams) } if s.P < scryptMinP { tlog.Fatal.Printf("Fatal: scrypt parameter P below minimum: value=%d, min=%d", s.P, scryptMinP) - os.Exit(1) + os.Exit(exitcodes.ScryptParams) } if len(s.Salt) < scryptMinSaltLen { tlog.Fatal.Printf("Fatal: scrypt salt length below minimum: value=%d, min=%d", len(s.Salt), scryptMinSaltLen) - os.Exit(1) + os.Exit(exitcodes.ScryptParams) } if s.KeyLen < cryptocore.KeyLen { tlog.Fatal.Printf("Fatal: scrypt parameter KeyLen below minimum: value=%d, min=%d", len(s.Salt), cryptocore.KeyLen) - os.Exit(1) + os.Exit(exitcodes.ScryptParams) } } -- cgit v1.2.3