Documentation
¶
Overview ¶
pkg/securex/hashx/algorithm.go Package hashx implements salted, self-describing, FIPS-140-3-aware one-way hashing and constant-time verification for passwords and other authentication material. PBKDF2-HMAC-SHA-256/512 are the only FIPS-approved algorithms; when FIPS 140-3 mode is active (pkg/securex/fipsx.IsFIPS) every other algorithm is refused fail-closed. Encoded outputs are PHC strings (argon2id/scrypt/pbkdf2) or native bcrypt modular-crypt; the leading "$id$" selects the verifier. Code generated by apic; DO NOT EDIT.
pkg/securex/hashx/argon2.go Code generated by apic; DO NOT EDIT.
pkg/securex/hashx/bcrypt.go Code generated by apic; DO NOT EDIT.
pkg/securex/hashx/hashx.go Code generated by apic; DO NOT EDIT.
pkg/securex/hashx/pbkdf2.go Code generated by apic; DO NOT EDIT.
pkg/securex/hashx/pepper.go Code generated by apic; DO NOT EDIT.
pkg/securex/hashx/phc.go Code generated by apic; DO NOT EDIT.
pkg/securex/hashx/policy.go Code generated by apic; DO NOT EDIT.
pkg/securex/hashx/scrypt.go Code generated by apic; DO NOT EDIT.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAlgorithmNotFIPSApproved = errors.New("hashx: algorithm not FIPS 140-3 approved")
ErrAlgorithmNotFIPSApproved is returned (fail-closed) when FIPS 140-3 mode is active but a non-approved algorithm is requested.
var ErrInvalidEncoding = errors.New("hashx: invalid encoded hash")
ErrInvalidEncoding is returned when a stored hash string cannot be parsed.
var ErrUnknownAlgorithm = errors.New("hashx: unknown algorithm")
ErrUnknownAlgorithm is returned for unrecognized algorithm names.
Functions ¶
func Hash ¶
Hash one-way hashes plaintext with algo and returns a self-describing encoded string (PHC or bcrypt crypt). It is fail-closed under FIPS: a non-approved algorithm yields ErrAlgorithmNotFIPSApproved and no hashing is performed.
func IsFIPSApproved ¶
IsFIPSApproved reports whether a is a FIPS-140-3-approved password KDF. Only PBKDF2 (NIST SP 800-132) qualifies.
func Verify ¶
func Verify(ctx context.Context, encoded string, plaintext []byte, opts ...Option) (ok bool, needsRehash bool, err error)
Verify reports whether plaintext matches encoded. needsRehash is true when the stored algorithm/params are weaker than current policy (upgrade-on-login). An unrecognized or malformed encoding is always a non-match error — never a match.
Types ¶
type Algorithm ¶
type Algorithm string
Algorithm names a password-hashing scheme.
func DefaultAlgorithm ¶
func DefaultAlgorithm() Algorithm
DefaultAlgorithm returns the policy default: a FIPS-approved KDF when FIPS mode is active, else Argon2id (OWASP's first choice).
func ParseAlgorithm ¶
ParseAlgorithm maps a config string to an Algorithm. "pbkdf2" is shorthand for PBKDF2SHA256 (OWASP's FIPS recommendation: HMAC-SHA-256 @ >=600k iterations).