Documentation
¶
Overview ¶
Package password exposes Nauthilus-compatible password comparison and full password-hash helpers for native Go plugins without importing server internals.
Index ¶
- Variables
- func CompareHash(hashPassword string, plainPassword pluginapi.Secret) (bool, error)
- func CompareHashBytes(hashPassword string, plainPassword []byte) (bool, error)
- func CompareHashString(hashPassword string, plainPassword string) (bool, error)
- func FullHash(value []byte) string
- func GenerateHash(secret pluginapi.Secret, options HashOptions) (string, error)
- func GenerateHashBytes(password []byte, options HashOptions) string
- func GenerateHashString(password string, options HashOptions) string
- func PrepareBytes(password []byte, nonce []byte) []byte
- type Algorithm
- type CryptPassword
- func (c *CryptPassword) GenerateBytes(plainPassword []byte, salt []byte, algorithm Algorithm, encoding Encoding) (string, error)
- func (c *CryptPassword) GenerateString(plainPassword string, salt []byte, algorithm Algorithm, encoding Encoding) (string, error)
- func (c *CryptPassword) GetParameters(cryptedPassword string) (salt []byte, algorithm Algorithm, encoding Encoding, err error)
- type Encoding
- type HashOptions
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnsupportedAlgorithm is returned for password hash algorithms outside the public helper contract. ErrUnsupportedAlgorithm = errors.New("unsupported hash algorithm") // ErrUnsupportedEncoding is returned for password hash payload encodings outside the public helper contract. ErrUnsupportedEncoding = errors.New("unsupported password encoding") )
Functions ¶
func CompareHash ¶
CompareHash verifies a public plugin secret against a stored Nauthilus-compatible password hash.
func CompareHashBytes ¶
CompareHashBytes verifies plain password bytes against a stored Nauthilus-compatible password hash.
func CompareHashString ¶
CompareHashString verifies a plain-text string against a stored Nauthilus-compatible password hash.
func GenerateHash ¶
func GenerateHash(secret pluginapi.Secret, options HashOptions) (string, error)
GenerateHash creates the Nauthilus full password hash for a public plugin secret.
func GenerateHashBytes ¶
func GenerateHashBytes(password []byte, options HashOptions) string
GenerateHashBytes creates the Nauthilus full hash for plain password bytes.
func GenerateHashString ¶
func GenerateHashString(password string, options HashOptions) string
GenerateHashString creates the Nauthilus full hash for a plain-text password string.
func PrepareBytes ¶
PrepareBytes applies the Nauthilus password nonce layout before hashing.
Types ¶
type Algorithm ¶
type Algorithm uint8
Algorithm identifies supported salted SHA password hash algorithms.
type CryptPassword ¶
CryptPassword stores parsed or generated salted SHA password material.
func (*CryptPassword) GenerateBytes ¶
func (c *CryptPassword) GenerateBytes(plainPassword []byte, salt []byte, algorithm Algorithm, encoding Encoding) (string, error)
GenerateBytes creates a salted SHA payload from plain password bytes.
func (*CryptPassword) GenerateString ¶
func (c *CryptPassword) GenerateString(plainPassword string, salt []byte, algorithm Algorithm, encoding Encoding) (string, error)
GenerateString creates a salted SHA payload from a plain-text password string.
func (*CryptPassword) GetParameters ¶
func (c *CryptPassword) GetParameters(cryptedPassword string) (salt []byte, algorithm Algorithm, encoding Encoding, err error)
GetParameters parses a salted SHA password hash and records the payload metadata.
type Encoding ¶
type Encoding uint8
Encoding identifies the payload encoding used by salted SHA password hashes.
type HashOptions ¶
type HashOptions struct {
Nonce []byte
// DevMode is retained for source compatibility and no longer changes hash output.
DevMode bool
}
HashOptions controls generated password hashes.