| 1 |
package bcrypt |
| 2 |
|
| 3 |
import ( |
| 4 |
"errors" |
| 5 |
"fmt" |
| 6 |
) |
| 7 |
|
| 8 |
var ( |
| 9 |
|
| 10 |
|
| 11 |
ErrMismatchedHashAndPassword = errors.New("github.com/go-crypt/x/bcrypt: the provided password is not a match for the provided hashed password") |
| 12 |
|
| 13 |
|
| 14 |
|
| 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 |
|
| 18 |
ErrSecretInvalidLength = errors.New("github.com/go-crypt/x/bcrypt: secret has an invalid length for a bcrypt secret") |
| 19 |
) |
| 20 |
|
| 21 |
|
| 22 |
|
| 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 |
|
| 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 |
} |