pbkdf2

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package pbkdf2 exposes the PBKDF2-SHA512 key stretching implementation used by ksf.

Index

Constants

View Source
const (
	// Name is the string identifier for the PBKDF2 key stretching function.
	Name = "PBKDF2-SHA512"

	// RecommendedSaltLength is the RFC recommended salt length for the PBKDF2 key stretching function.
	RecommendedSaltLength = 8

	// DefaultIterations is the default iterations parameter for the PBKDF2 key stretching function.
	DefaultIterations = 10000
)

Variables

View Source
var (
	// ErrParams indicates an invalid amount of PBKDF2 parameters.
	ErrParams = errors.New("invalid amount of PBKDF2 parameters")

	// ErrParameterValue indicates that one or more PBKDF2 parameters have invalid values.
	ErrParameterValue = errors.New("invalid PBKDF2 parameter value")

	// ErrOutputLength indicates that the requested derived key length is invalid.
	ErrOutputLength = errors.New("invalid PBKDF2 output length")
)

Functions

func DefaultParameters

func DefaultParameters() []uint64

DefaultParameters returns the default PBKDF2 iterations parameter as a slice of uint64.

func Harden

func Harden(password, salt []byte, length int, parameters ...uint64) ([]byte, error)

Harden uses the PBKDF2 key stretching function to derive a key from the password and salt. The parameter must be empty or a single value representing the number of iterations. If no parameters are provided, the recommended default values will be used.

func UnsafeHarden

func UnsafeHarden(password, salt []byte, length int, parameters ...uint64) []byte

UnsafeHarden is the same as Harden but panics on an invalid parameter. It is safe to use if the parameter has previously been validated by ValidateParameters.

func ValidateParameters

func ValidateParameters(parameters ...uint64) error

ValidateParameters checks if the provided parameter is valid for the PBKDF2 key stretching function. The parameter must be empty or a single value representing the number of iterations.

Types

This section is empty.

Jump to

Keyboard shortcuts

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