Documentation ¶
Overview ¶
Package makwa implements the Makwa password hashing algorithm.
Makwa is a candidate in the Password Hashing Competition which uses squaring modulo Blum integers to provide a one-way function with number-theoretic security.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBadBase64 = errors.New("bad base64")
ErrBadBase64 is returned when the provided Base64 value cannot be decoded.
var ErrBadPassword = errors.New("bad password")
ErrBadPassword is returned when a bad password is provided.
var ErrInvalidWorkFactor = errors.New("invalid work factor")
ErrInvalidWorkFactor is returned when the given work factor cannot be encoded as a power of 2 or 3.
var ErrWrongParams = errors.New("wrong parameters")
ErrWrongParams is returned when a password is being checked using the wrong parameters.
Functions ¶
func CheckPassword ¶
func CheckPassword(params PublicParameters, digest *Digest, password []byte) error
CheckPassword safely compares a password to a digest of a password.
Types ¶
type Digest ¶
type Digest struct { ModulusID []byte Hash []byte Salt []byte WorkFactor int PreHash bool PostHashLen int }
A Digest is a hashed password.
func Hash ¶
func Hash(params PublicParameters, password, salt []byte, workFactor int, preHash bool, postHashLen int) (*Digest, error)
Hash returns a digest of the given password using the given parameters. If the given salt is nil, generates a random salt of sufficient length.
func (*Digest) MarshalText ¶
MarshalText marshals a digest into a text format.
func (*Digest) UnmarshalText ¶
UnmarshalText unmarshals a digest from a text format.
type PrivateParameters ¶
type PrivateParameters struct { PublicParameters P, Q *big.Int }
PrivateParameters are the private parameters associated with Makwa.
func GenerateParameters ¶
func GenerateParameters(bits int) (*PrivateParameters, error)
GenerateParameters generates a random Makwa modulus of the given size.
type PublicParameters ¶
PublicParameters are the public parameters associated with Makwa.
func (PublicParameters) ModulusID ¶
func (p PublicParameters) ModulusID() []byte
ModulusID returns a fingerprint of the modulus.