Debian Codegraph @

bcrypt/errors.go

raw symbols SCIP
1 package bcrypt
2
3 import (
4 "errors"
5 "fmt"
6 )
7
8 var (
9 // ErrMismatchedHashAndPassword is the error returned from CompareHashAndPassword when a password and hash do
10 // not match.
11 ErrMismatchedHashAndPassword = errors.New("github.com/go-crypt/x/bcrypt: the provided password is not a match for the provided hashed password")
12
13 // ErrHashTooShort is the error returned from CompareHashAndPassword when a hash is too short to
14 // be a bcrypt hash.
15 ErrHashTooShort = errors.New("github.com/go-crypt/x/bcrypt: hashed secret key is too short to be a bcrypt hashed secret key")
16
17 // ErrSecretInvalidLength is the error returned when a hash secret is too short to be a bcrypt secret.
18 ErrSecretInvalidLength = errors.New("github.com/go-crypt/x/bcrypt: secret has an invalid length for a bcrypt secret")
19 )
20
21 // The error returned from CompareHashAndPassword when a hash was created with
22 // a bcrypt algorithm newer than this implementation.
23 type HashVersionTooNewError byte
24
25 func (hv HashVersionTooNewError) Error() string {
26 return fmt.Sprintf("github.com/go-crypt/x/bcrypt: bcrypt algorithm version '%c' requested is newer than current version '%c'", byte(hv), majorVersion)
27 }
28
29 // The error returned from CompareHashAndPassword when a hash starts with something other than '$'
30 type InvalidHashPrefixError byte
31
32 func (ih InvalidHashPrefixError) Error() string {
33 return fmt.Sprintf("github.com/go-crypt/x/bcrypt: bcrypt hashes must start with '$', but hashedSecret started with '%c'", byte(ih))
34 }
35
36 type InvalidCostError int
37
38 func (ic InvalidCostError) Error() string {
39 return fmt.Sprintf("github.com/go-crypt/x/bcrypt: cost %d is outside allowed inclusive range %d..%d", int(ic), MinCost, MaxCost)
40 }
41
42 type InvalidSaltSizeError struct {
43 salt []byte
44 }
45
46 func (iss InvalidSaltSizeError) Error() string {
47 return fmt.Sprintf("github.com/go-crypt/x/bcrypt: salt %x with byte length %d does not have the correct byte length %d", iss.salt, len(iss.salt), maxSaltSize)
48 }