ksf

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

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

View Source
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

type Option func(KSF) error

Option type indicates option functions

func WithArgon2Memory

func WithArgon2Memory(memory int) Option

WithArgon2Memory sets argon algorithm's memory parameter. This option must used with only argon instance

func WithArgon2Threads

func WithArgon2Threads(threads int) Option

WithArgon2Threads sets argon algorithm's threads parameter. This option must used with only argon instance

func WithArgon2Time

func WithArgon2Time(time int) Option

WithArgon2Time sets argon algorithm's time parameter. This option must used with only argon instance

func WithBcryptCost

func WithBcryptCost(cost int) Option

WithBcryptCost sets bcrypt algorithm's cost parameter. This option must used with only bcrypt instance

func WithScryptN

func WithScryptN(n int) Option

WithScryptN sets scrypt algorithm's n parameter. This option must used with only scrypt instance

func WithScryptP

func WithScryptP(p int) Option

WithScryptP sets scrypt algorithm's p parameter. This option must used with only scrypt instance

func WithScryptR

func WithScryptR(r int) Option

WithScryptR sets scrypt algorithm's r parameter. This option must used with only scrypt instance

Jump to

Keyboard shortcuts

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