Documentation
¶
Overview ¶
Package argon2 provides salt generation, hashing and verification for x/crypto/argon2.
Index ¶
Constants ¶
View Source
const ( Identifier_i = "argon2i" Identifier_d = "argon2d" // Unsupported Identifier_id = "argon2id" Prefix = "$argon2" )
Argon2 identifiers
View Source
const ( DefaultMinTime = 1 DefaultMaxTime = 10 DefaultMinMemory = 8 * 1024 DefaultMaxMemory = 512 * 1024 DefaultMinThreads = 1 DefaultMaxThreads = 16 )
Validation defaults
View Source
const Format = "$%s$v=%d$m=%d,t=%d,p=%d$%s$%s"
Format of the PHC string format for argon2. See https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md.
Variables ¶
View Source
var ( RecommendedIParams = Params{ Time: 3, Memory: 32 * 1024, Threads: 4, KeyLen: 32, SaltLen: 16, } RecommendedIDParams = Params{ Time: 1, Memory: 64 * 1024, Threads: 4, KeyLen: 32, SaltLen: 16, } )
View Source
var ( ErrArgon2d = errors.New("argon2d is not supported") ErrArgon2Version = fmt.Errorf("argon2: version required %x", argon2.Version) )
View Source
var DefaultValidationOpts = &ValidationOpts{ MinTime: DefaultMinTime, MaxTime: DefaultMaxTime, MinMemory: DefaultMinMemory, MaxMemory: DefaultMaxMemory, MinThreads: DefaultMinThreads, MaxThreads: DefaultMaxThreads, }
Functions ¶
This section is empty.
Types ¶
type Hasher ¶
type Hasher struct {
// contains filtered or unexported fields
}
func NewArgon2i ¶
func NewArgon2i(p Params, opts *ValidationOpts) *Hasher
func NewArgon2id ¶
func NewArgon2id(p Params, opts *ValidationOpts) *Hasher
type Params ¶
type Params struct {
Time uint32
Memory uint32
Threads uint8
KeyLen uint32
SaltLen uint32
// contains filtered or unexported fields
}
Params are used for all argon2 modes.
type ValidationOpts ¶ added in v0.12.0
type Verifier ¶
type Verifier struct {
// contains filtered or unexported fields
}
func NewVerifier ¶ added in v0.12.0
func NewVerifier(opts *ValidationOpts) *Verifier
func (*Verifier) Verify ¶ added in v0.12.0
Verify parses encoded and uses its argon2 parameters to verify password against its hash. Either the result of Fail or OK is returned, or an error if parsing fails.
Note that argon2d is not supported by upstream and therefore not by this package. ErrArgon2d is returned when an argon2d identifier is in the encoded string.
Click to show internal directories.
Click to hide internal directories.