diff --git a/credential.go b/credential.go index 81b21b6..ebb15ab 100644 --- a/credential.go +++ b/credential.go @@ -2,7 +2,7 @@ package passhash import ( "crypto/subtle" - "fmt" + "errors" "golang.org/x/crypto/bcrypt" "net" ) @@ -115,7 +115,7 @@ func (c *Credential) ChangePasswordWithConfig(config Config, oldPassword, newPas // ChangePasswordWithConfigAndIP changes the password for the given Credential and updates the Credential to meet the Config parameters if necessary func (c *Credential) ChangePasswordWithConfigAndIP(config Config, oldPassword, newPassword string, ip net.IP) error { if !c.matchPassword(oldPassword, config.AuditLogger, ip) { - return fmt.Errorf("Old password does not match existing password") + return errors.New("Old password does not match existing password") } return c.ResetWithConfigAndIP(config, newPassword, ip) } diff --git a/passhash.go b/passhash.go index 021321e..e58ce47 100644 --- a/passhash.go +++ b/passhash.go @@ -2,6 +2,7 @@ package passhash import ( "crypto" + "errors" "fmt" "golang.org/x/crypto/bcrypt" "golang.org/x/crypto/pbkdf2" @@ -91,16 +92,16 @@ func getPasswordHash(kdf Kdf, workFactor WorkFactor, salt []byte, keyLength int, case Pbkdf2Sha3_512: return pbkdf2.Key([]byte(password), salt, wf.Iter, keyLength, sha3.New512), nil default: - return []byte{}, fmt.Errorf("Pbkdf2WorkFactor can only be specified with the Pbkdf2 Kdf") + return []byte{}, errors.New("Pbkdf2WorkFactor can only be specified with the Pbkdf2 Kdf") } case *BcryptWorkFactor: if kdf != Bcrypt { - return []byte{}, fmt.Errorf("BcryptWorkFactor can only be specified with the Bcrypt Kdf") + return []byte{}, errors.New("BcryptWorkFactor can only be specified with the Bcrypt Kdf") } return bcrypt.GenerateFromPassword([]byte(password), wf.Cost) case *ScryptWorkFactor: if kdf != Scrypt { - return []byte{}, fmt.Errorf("ScryptWorkFactor can only be specified with the Scrypt Kdf") + return []byte{}, errors.New("ScryptWorkFactor can only be specified with the Scrypt Kdf") } return scrypt.Key([]byte(password), salt, wf.N, wf.R, wf.P, keyLength) default: diff --git a/password_policies.go b/password_policies.go index 37b54ff..289087d 100644 --- a/password_policies.go +++ b/password_policies.go @@ -1,6 +1,7 @@ package passhash import ( + "errors" "fmt" "strings" "unicode/utf8" @@ -56,7 +57,7 @@ type NotCommonPasswordNaive struct { // PasswordAcceptable accepts passwords that are not common passwords func (pp NotCommonPasswordNaive) PasswordAcceptable(password string) error { if pp.CommonPasswords[password] { - return fmt.Errorf("Password is a common password") + return errors.New("Password is a common password") } return nil } diff --git a/store.go b/store.go index 63c4b37..b07262f 100644 --- a/store.go +++ b/store.go @@ -2,7 +2,7 @@ package passhash import ( "context" - "fmt" + "errors" ) // CredentialStore is an interfance for customizing Credential storage @@ -24,10 +24,10 @@ func (d DummyCredentialStore) StoreContext(context.Context, *Credential) error { // Load only returns errors func (d DummyCredentialStore) Load(UserID) (*Credential, error) { - return nil, fmt.Errorf("DummyCredentialStore does not support loading credentials") + return nil, errors.New("DummyCredentialStore does not support loading credentials") } // LoadContext only returns errors func (d DummyCredentialStore) LoadContext(context.Context, UserID) (*Credential, error) { - return nil, fmt.Errorf("DummyCredentialStore does not support loading credentials") + return nil, errors.New("DummyCredentialStore does not support loading credentials") }