diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2018-08-24 21:12:11 -0400 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2018-09-24 23:22:40 -0400 |
| commit | cc0dc067c7362adfb1de802c86c3bab1601b5fe0 (patch) | |
| tree | a59826f272902b2ba138c95e3a1eba6cfad7dda6 /crypto | |
| parent | 2eeb9a78c06835db36b2df169e26334cb9d65c86 (diff) | |
Return error instead of using log.Fatal
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'crypto')
| -rw-r--r-- | crypto/pbkdf2.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/crypto/pbkdf2.go b/crypto/pbkdf2.go index d5217429..683194ba 100644 --- a/crypto/pbkdf2.go +++ b/crypto/pbkdf2.go @@ -5,9 +5,10 @@ import ( "crypto/sha1" //nolint: gosec "crypto/sha256" "crypto/sha512" - "fmt" "hash" + "github.com/pkg/errors" + "golang.org/x/crypto/pbkdf2" ) @@ -42,7 +43,7 @@ func StrToHash(hash string) (crypto.Hash, error) { case "SHA512_256", "SHA512/256", "SHA-512_256", "SHA-512/256": return crypto.SHA512_256, nil } - return 0, fmt.Errorf("no such hash %s", hash) + return 0, errors.Errorf("no such hash %s", hash) } // PBKDF2 - Run the Password-Based Key Derivation Function #2 as defined in @@ -50,7 +51,7 @@ func StrToHash(hash string) (crypto.Hash, error) { func PBKDF2(password, salt []byte, iter, keylen int, hashFunc crypto.Hash) ([]byte, error) { h, ok := hashFuncs[hashFunc] if !ok { - return nil, fmt.Errorf("hashFunc not supported: %v", hashFunc) + return nil, errors.Errorf("hashFunc not supported: %v", hashFunc) } return pbkdf2.Key(password, salt, iter, keylen, h), nil } |
