Documentation ¶
Overview ¶
Package scrypt implements a password encoding mechanism for the mcf framework
Index ¶
Constants ¶
const ( DefaultKeyLen = 32 DefaultSaltLen = 16 DefaultN = 1 << 16 DefaultR = 10 DefaultP = 2 )
Circa 2014 work factors. These are exported to show default values. See GetConfig and SetConfig(...) to change them.
Variables ¶
var SaltMine mcf.SaltMiner = nil
Custom source of salt, normally unset. Set this if you need to override the user of rand.Reader and use a custom salt producer. Also useful for testing.
Functions ¶
func SetConfig ¶
SetConfig sets the default encoding parameters, salt length or key length. It is best to modify a copy of the default configuration unless all parameters are changed.
Here is an example that doubles the default work factor.
config := scrypt.GetConfig() config.N *= 2 scrypt.SetConfig(config)
Types ¶
type Config ¶
type Config struct { KeyLen int //Key output size in bytes. SaltLen int // Length of salt in bytes. N int // CPU/Memory cost. Must be a power of two. R int // block size parameter. P int // parallelization parameter. }
Config contains the scrypt algorithm parameters and other associated values. Use the GetConfig() and SetConfig() combination to change any desired parameters.
func GetConfig ¶
func GetConfig() Config
Config returns the default configuration used to create new scrypt password hashes. The return value can be modified and used as a parameter to SetConfig
func (*Config) AtLeast ¶
func (c *Config) AtLeast(current_imp bridge.Implementer) bool
AtLeast returns true if the parameters used to generate the encoded password are at least as good as those currently in use.
func (*Config) Key ¶
Key returns an scrypt digest of password and salt using the algorithm parameters: N, r, and p. The returned value is of length KeyLen.
type ErrInvalidParameter ¶
ErrInvalidParameter is returned by SetConfig if any of the provided parameters fail validation. The error message contains the name and value of the faulty parameter to aid in resolving the problem.
func (ErrInvalidParameter) Error ¶
func (e ErrInvalidParameter) Error() string