argon2

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2024 License: BSD-3-Clause Imports: 10 Imported by: 1

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 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)
)

Functions

func Verify

func Verify(encoded, password string) (verifier.Result, error)

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.

Types

type Hasher

type Hasher struct {
	// contains filtered or unexported fields
}

func NewArgon2i

func NewArgon2i(p Params) *Hasher

func NewArgon2id

func NewArgon2id(p Params) *Hasher

func (*Hasher) Hash

func (h *Hasher) Hash(password string) (string, error)

Hash implements passwap.Hasher.

func (*Hasher) Verify

func (h *Hasher) Verify(encoded, password string) (verifier.Result, error)

Verify implements passwap.Verifier

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL