ksf

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2022 License: MIT Imports: 8 Imported by: 2

README

Cryptographic Key Stretching Functions

ksf Go Reference codecov

  import "github.com/bytemare/ksf"

This package exposes a simple API to seamlessly use a variety of key stretching functions, also used as key derivation functions. It aims at minimum code adaptation in your code, and easy parameterization. It completely relies on built-ins, so there's no change in implementations.

Supported Key Stretching Functions (or Key Derivation Functions are):

  • Argon2 family
  • bcrypt
  • Scrypt
  • PBKDF2
What is ksf?

In cryptography, key stretching techniques are used to make a possibly weak key, typically a password or passphrase, more secure against a brute-force attack by increasing the resources (time and possibly space) it takes to test each possible key.

Wikipedia

Documentation Go Reference

You can find the documentation and usage examples in the package doc and the project wiki .

Versioning

SemVer is used for versioning. For the versions available, see the tags on the repository.

Contributing

Please read CONTRIBUTING.md for details on the code of conduct, and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Overview

Package ksf provides an interface to key stretching functions, a.k.a password key derivation functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Salt

func Salt(length int) []byte

Salt returns random bytes of length len (wrapper for crypto/rand).

Types

type Identifier

type Identifier byte

Identifier is used to specify the key stretching function to be used.

const (
	// Argon2id password kdf function.
	Argon2id Identifier = 1 + iota

	// Scrypt password kdf function.
	Scrypt

	// PBKDF2Sha512 PBKDF2 password kdf function using SHA-512.
	PBKDF2Sha512

	// Bcrypt password kdf function.
	Bcrypt
)

func (Identifier) Available

func (i Identifier) Available() bool

Available reports whether the given kdf function is linked into the binary.

func (Identifier) Get

func (i Identifier) Get() *KSF

Get returns a KSF with default parameters.

func (Identifier) Harden

func (i Identifier) Harden(password, salt []byte, length int) []byte

Harden uses default parameters for the key derivation function over the input password and salt.

func (Identifier) String

func (i Identifier) String() string

String returns the string name of the hashing function.

type KSF

type KSF struct {
	// contains filtered or unexported fields
}

KSF allows customisation of the underlying key stretching function.

Jump to

Keyboard shortcuts

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