-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
66 lines (50 loc) · 3.17 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package algorithm
import (
"errors"
)
var (
// ErrEncodedHashInvalidFormat is an error returned when an encoded hash has an invalid format.
ErrEncodedHashInvalidFormat = errors.New("provided encoded hash has an invalid format")
// ErrEncodedHashInvalidIdentifier is an error returned when an encoded hash has an invalid identifier for the
// given digest.
ErrEncodedHashInvalidIdentifier = errors.New("provided encoded hash has an invalid identifier")
// ErrEncodedHashInvalidVersion is an error returned when an encoded hash has an unsupported or otherwise invalid
// version.
ErrEncodedHashInvalidVersion = errors.New("provided encoded hash has an invalid version")
// ErrEncodedHashInvalidOption is an error returned when an encoded hash has an unsupported or otherwise invalid
// option in the option field.
ErrEncodedHashInvalidOption = errors.New("provided encoded hash has an invalid option")
// ErrEncodedHashInvalidOptionKey is an error returned when an encoded hash has an unknown or otherwise invalid
// option key in the option field.
ErrEncodedHashInvalidOptionKey = errors.New("provided encoded hash has an invalid option key")
// ErrEncodedHashInvalidOptionValue is an error returned when an encoded hash has an unknown or otherwise invalid
// option value in the option field.
ErrEncodedHashInvalidOptionValue = errors.New("provided encoded hash has an invalid option value")
// ErrEncodedHashKeyEncoding is an error returned when an encoded hash has a salt with an invalid or unsupported
// encoding.
ErrEncodedHashKeyEncoding = errors.New("provided encoded hash has a key value that can't be decoded")
// ErrEncodedHashSaltEncoding is an error returned when an encoded hash has a salt with an invalid or unsupported
// encoding.
ErrEncodedHashSaltEncoding = errors.New("provided encoded hash has a salt value that can't be decoded")
// ErrKeyDerivation is returned when a Key function returns an error.
ErrKeyDerivation = errors.New("failed to derive the key with the provided parameters")
// ErrSaltEncoding is an error returned when a salt has an invalid or unsupported encoding.
ErrSaltEncoding = errors.New("provided salt has a value that can't be decoded")
// ErrPasswordInvalid is an error returned when a password has an invalid or unsupported properties. It is NOT
// returned on password mismatches.
ErrPasswordInvalid = errors.New("password is invalid")
// ErrSaltInvalid is an error returned when a salt has an invalid or unsupported properties.
ErrSaltInvalid = errors.New("salt is invalid")
// ErrSaltReadRandomBytes is an error returned when generating the random bytes for salt resulted in an error.
ErrSaltReadRandomBytes = errors.New("could not read random bytes for salt")
// ErrParameterInvalid is an error returned when a parameter has an invalid value.
ErrParameterInvalid = errors.New("parameter is invalid")
)
// Error format strings.
const (
ErrFmtInvalidIntParameter = "%w: parameter '%s' must be between %d%s and %d but is set to '%d'"
ErrFmtDigestDecode = "%s decode error: %w"
ErrFmtDigestMatch = "%s match error: %w"
ErrFmtHasherHash = "%s hashing error: %w"
ErrFmtHasherValidation = "%s validation error: %w"
)