sp800108

package
v0.0.0-...-ec355d6 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package sp800108 implements the NIST Special Publication 800-108

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

type Counter uint8

Counter defines a valid counter length

const (
	// CounterLength8 is an 8-bit counter
	CounterLength8 Counter = 8
	// CounterLength16 is a 16-bit counter
	CounterLength16 Counter = 16
	// CounterLength24 is a 24-bit counter
	CounterLength24 Counter = 24
	// CounterLength32 is a 32-bit counter
	CounterLength32 Counter = 32
)

type CounterKBKDF

type CounterKBKDF struct{}

CounterKBKDF is the NIST Key Based Key Derivation Function in counter mode

func (*CounterKBKDF) Derive

func (c *CounterKBKDF) Derive(prf PRF, counterLengthR Counter, inputKey, label, context, outputSizeBits []byte, inputOrder []InputStringOrdering) ([]byte, error)

Derive uses the key and keying material to generate a derived key(set) of the desired size

type InputStringOrdering

type InputStringOrdering uint

InputStringOrdering defines an element in the KDF Input String

const (
	// InputOrderLabel is the label
	InputOrderLabel InputStringOrdering = iota
	// InputOrderContext is the context
	InputOrderContext
	// InputOrderL is the output data length as big-endian binary integer L
	InputOrderL
	// InputOrderEmptySeparator is 0x00
	InputOrderEmptySeparator
	// InputOrderCounter is the counter variable
	InputOrderCounter
)

type KDF

type KDF interface {
	// Derive uses the key and keying material to generate a derived key(set) of the desired size. Output size is big-endian
	Derive(prf PRF, counterLengthR Counter, inputKey, label, context, outputSizeBits []byte, inputOrder []InputStringOrdering) ([]byte, error)
}

KDF is a Key Derivation Function

type PRF

type PRF interface {
	// Compute generates new data from a key and keying material data.
	Compute(key, data []byte) ([]byte, error)
	// OutputSizeBytes indicates the output size of the PRF in bytes, non-byte multiples of output length are not supported
	OutputSizeBytes() uint
	// contains filtered or unexported methods
}

PRF is a Pseudorandom Function acceptable to the NIST KBKDF

type PRFCMAC

type PRFCMAC struct{}

PRFCMAC is the CMAC implementation of PRF

func (*PRFCMAC) Compute

func (p *PRFCMAC) Compute(key, data []byte) ([]byte, error)

Compute generatesd new data from a key and keying material data

func (*PRFCMAC) OutputSizeBytes

func (p *PRFCMAC) OutputSizeBytes() uint

OutputSizeBytes indicates the output size of the PRF in bytes, non-byte multiples of output length are not supported

type PRFHMAC

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

PRFHMAC is the HMAC implementation of PRF

func NewPRFHMAC

func NewPRFHMAC(hashGen func() hash.Hash) *PRFHMAC

NewPRFHMAC creates a new HMAC PRF

func (*PRFHMAC) Compute

func (p *PRFHMAC) Compute(key, data []byte) ([]byte, error)

Compute generatesd new data from a key and keying material data

func (*PRFHMAC) OutputSizeBytes

func (p *PRFHMAC) OutputSizeBytes() uint

OutputSizeBytes indicates the output size of the PRF in bytes, non-byte multiples of output length are not supported

Jump to

Keyboard shortcuts

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