argon2

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package argon2 implements auth's Authenticator interface using the argon2 key derivation function.

Index

Constants

View Source
const (
	DefaultMemory      uint32 = 64 * 1024
	DefaultIterations  uint32 = 3
	MinimumParallelism uint8  = 1
	MinimumSaltLen     uint32 = 8
	DefaultSaltLen     uint32 = 16
	MinimumKeyLen      uint32 = 16
	DefaultKeyLen      uint32 = 32
)

Variables

View Source
var (
	ErrInvalidHash         = errors.New("hash is not a valid argon2 hash")
	ErrIncompatibleVersion = errors.New("hash version differs from Go library's implemented version")
	ErrUnknownAlgorithm    = errors.New("unknown algorithm")
	ErrSaltLenTooSmall     = errors.New("salt length is too small")
	ErrParallelismTooSmall = errors.New("degree of parallelism is too small")
	ErrKeyLenTooSmall      = errors.New("key length is too small")
	ErrHashAndPassNotMatch = errors.New("password does not Match the Hash")
)
View Source
var (
	DefaultAuthenticator = &Authenticator{DefaultCtx}
)

Functions

func IsHash added in v1.0.3

func IsHash(candidate string) bool

IsHash returns, whether candidate is a valid argon2 hash.

Types

type Algorithm

type Algorithm string
const (
	Argon2i  Algorithm = "argon2i"
	Argon2id Algorithm = "argon2id"
)

type Authenticator

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

func NewAuthenticator

func NewAuthenticator(ctx *Context) (*Authenticator, error)

func (*Authenticator) Compare

func (a *Authenticator) Compare(hash, plaintext string) error

func (*Authenticator) Hash

func (a *Authenticator) Hash(plaintext string) (string, error)

type Context

type Context struct {
	Algorithm  Algorithm
	Version    uint8
	Memory     uint32
	Iterations uint32
	Threads    uint8
	SaltLen    uint32
	KeyLen     uint32
}

Jump to

Keyboard shortcuts

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