kdf

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: BSD-3-Clause Imports: 5 Imported by: 2

Documentation

Overview

Package kdf contains useful key derivation functions.

Index

Constants

View Source
const (
	// Default repititions to use to derive a key.
	DefaultReps = 1972
)

Variables

View Source
var (
	// Default salt
	DefaultSalt = []byte{0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0xAB, 0x24}
)

Functions

func KDF

func KDF(plain []byte, salt []byte, reps int) []byte

KDF derives a 32 byte encryption key from plain by using salt and reps repititions. The larger reps is, the longer it takes to drive the key. For a given plain text, salt, and reps, KDF will consistently produce the same encryption key.

func NewHMAC

func NewHMAC(plain []byte, reps int) []byte

NewHMAC creates a one way hash of plain performing reps repitition. Resulting hash is 40 bytes and contains 8 bytes of random salt. The larger reps is the longer it takes to build the hash.

func Random

func Random(count int) []byte

Random produces a random sequence of count bytes

func VerifyHMAC

func VerifyHMAC(plain []byte, mac []byte, reps int) bool

VerifyHMAC returns true if mac is a valid one way hash of plain. reps must be the same as what was passed to NewHMAC to create the one way hash.

Types

This section is empty.

Jump to

Keyboard shortcuts

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