bridge

package
v0.0.0-...-eca9d05 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: GPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(name []byte, fn func() Implementer) encoder.Encoder

New takes an implementation name and a function that produces an Implementer and produces an encoder.Encoder that uses the Implementer.

Types

type Encoder

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

Encoder implements the encoder.Encoder interface using an Implementer to abstract implementation specific parts.

func (*Encoder) Create

func (enc *Encoder) Create(plaintext []byte) (encoded []byte, err error)

Create produces an encoded password from a plaintext password using the current configuration. The application must store the encoded password for future use.

func (*Encoder) Id

func (enc *Encoder) Id() []byte

Id returns the name of the encoder, which is the type of passwords it can handle.

func (*Encoder) IsCurrent

func (enc *Encoder) IsCurrent(encoded []byte) (isCurrent bool, err error)

IsCurrent returns true if the parameters used to generate the encoded password are at least as good as those in params. If IsCurrent returns false the encoding is out of date and should be regenerated, the application should call mcf.Create() to produce a new encoding to replace the current one.

func (*Encoder) Verify

func (enc *Encoder) Verify(plaintext, encoded []byte) (isValid bool, err error)

Verify returns true if the proffered plaintext password, when encoded using the same parameters, matches the encoded password.

type Implementer

type Implementer interface {
	// Params encodes the parameters used by Key.
	Params() string

	// Setparams restores parameters from string produced by Params.
	SetParams(string) error

	// Produces required amount of salt.
	Salt() ([]byte, error)

	// Key generates a key (hash, digest, key) using password, salt and implementer specific parameters.
	Key(password, salt []byte) ([]byte, error)

	// AtLeast compares the implementer to the current implementer and determines whether the
	// implementer parameters are at least as strong as the current. It is used to determine
	// whether an encoded password needs to be re-encoded.
	AtLeast(Implementer) bool
}

Implementer represents a concrete implementation such as scrypt or pbkdf2

Jump to

Keyboard shortcuts

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