Documentation ¶
Overview ¶
Package ksf is a small wrapper around built-in cryptographic key strech functions to make their usage easier and safer
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotArgon2 returns when non argon2 option passed to SetOptions function. ErrNotArgon2 = errors.New("ksf: instance is not argon2") // ErrNotBcrypt returns when non bcrypt option passed to SetOptions function. ErrNotBcrypt = errors.New("ksf: instance is not bcrypt") // ErrNotScrypt returns when non scrypt option passed to SetOptions function. ErrNotScrypt = errors.New("ksf: instance is not scrypt") // ErrNotSupportedAlgorithm returns non supported ksf algorithm selected. ErrNotSupportedAlgorithm = errors.New("ksf: algorithm not supported") )
Functions ¶
This section is empty.
Types ¶
type Identifier ¶
type Identifier uint
Identifier is the type for supported ksf functions
const ( // Identity identifier Identity Identifier = iota // Argon2id identfier Argon2id // Bcrypt identifier Bcrypt // Scrypt identifier Scrypt )
func (Identifier) New ¶
func (i Identifier) New() KSF
New returns a new KSF instance of receiver identifier
type KSF ¶
type KSF interface { // Harden uses default parameters (if custom option is not applied) for the key derivation function over the input password and salt Harden(password, salt []byte, length int) ([]byte, error) // SetOptions lets change the functions parameters with the new ones SetOptions(options ...Option) error // String returns the string representation with current parameters String() string }
KSF is an interface that identifies the supported KSF algorithms
type Option ¶
Option type indicates option functions
func WithArgon2Memory ¶
WithArgon2Memory sets argon algorithm's memory parameter. This option must used with only argon instance
func WithArgon2Threads ¶
WithArgon2Threads sets argon algorithm's threads parameter. This option must used with only argon instance
func WithArgon2Time ¶
WithArgon2Time sets argon algorithm's time parameter. This option must used with only argon instance
func WithBcryptCost ¶
WithBcryptCost sets bcrypt algorithm's cost parameter. This option must used with only bcrypt instance
func WithScryptN ¶
WithScryptN sets scrypt algorithm's n parameter. This option must used with only scrypt instance
func WithScryptP ¶
WithScryptP sets scrypt algorithm's p parameter. This option must used with only scrypt instance
func WithScryptR ¶
WithScryptR sets scrypt algorithm's r parameter. This option must used with only scrypt instance