passwordauth

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package passwordauth hashes and verifies local account passwords with argon2id. Hashes are stored in the PHC string format so they stay self-describing: a hash written with today's cost parameters still verifies after the defaults below are raised.

Index

Constants

View Source
const (
	MinPasswordLength = 8
	// MaxPasswordLength bounds the work an unauthenticated caller can ask for.
	MaxPasswordLength = 256
)

Variables

View Source
var (
	ErrPasswordTooShort = fmt.Errorf("password must be at least %d characters", MinPasswordLength)
	ErrPasswordTooLong  = fmt.Errorf("password must be at most %d characters", MaxPasswordLength)
	ErrInvalidHash      = errors.New("password hash is not a supported argon2id encoding")
)

Functions

func Hash

func Hash(ctx context.Context, password string) (string, error)

Hash derives a new argon2id hash and returns it in PHC string format.

func ValidatePassword

func ValidatePassword(password string) error

ValidatePassword reports whether a candidate secret is acceptable to store.

func Verify

func Verify(ctx context.Context, encoded, password string) (bool, error)

Verify reports whether password matches the encoded hash. It compares in constant time; mismatches return false without an error, while cancellation and invalid hashes return an error rather than a failed guess.

func VerifyDecoy

func VerifyDecoy(ctx context.Context, password string) error

VerifyDecoy pays the same derivation cost for unknown or unenrolled accounts.

Types

This section is empty.

Jump to

Keyboard shortcuts

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