scrypth64

package module
v0.0.0-...-4c4328d Latest Latest
Warning

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

Go to latest
Published: May 21, 2016 License: BSD-2-Clause Imports: 8 Imported by: 6

README

scrypt-h64 for Go

package scrypth64 // import "github.com/mjolnir42/scrypth64"

scrypth64 derives password hashes and verifies passwords against them
according to the scrypt-h64 specification. It includes a number of ready to
use parameter sets. The modular crypt format is used, and its de-facto
standard as well as historic precedents are followed.

func Digest(password string, params *Parameter) (Mcf, error)
func Verify(password string, mcf Mcf) (bool, error)
type Parameter struct { ... }
func DefaultParams() *Parameter
func HighParams() *Parameter
func PaperParams() *Parameter
type Mcf string
func (m Mcf) FromString(s string) (res Mcf, err error)

func Digest(password string, params *Parameter) (Mcf, error)
    Digest calculates a new scrypt digest and returns it as a scrypt-h64 MCF
    formatted string. If params is nil, DefaultParams are used. Returns an empty
    string if err != nil.

func Verify(password string, mcf Mcf) (bool, error)
    Verify takes a password and a scrypt-h64 string in MCF format and returns
    true is the password matches the provided digest. The result is always false
    if error != nil.

func (m Mcf) FromString(s string) (res Mcf, err error)
    FromString takes a string, validates it and returns it as a custom typed Mcf
    string.

Specification

See separate file Specification.md

Documentation

Overview

scrypth64 derives password hashes and verifies passwords against them according to the scrypt-h64 specification. It includes a number of ready to use parameter sets. The modular crypt format is used, and its de-facto standard as well as historic precedents are followed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Verify

func Verify(password string, mcf Mcf) (bool, error)

Verify takes a password and a scrypt-h64 string in MCF format and returns true if the password matches the provided digest. The result is always false if error != nil.

Types

type Mcf

type Mcf string

Mcf is a custom string type to indicate that the underlying string is subject to specific formatting rules

func Digest

func Digest(password string, params *Parameter) (Mcf, error)

Digest calculates a new scrypt digest and returns it as a scrypt-h64 MCF formatted string. If params is nil, DefaultParams are used. Returns an empty string if err != nil.

func FromString

func FromString(s string) (res Mcf, err error)

FromString takes a string, validates it and returns it as a custom typed Mcf string.

func (Mcf) String

func (m Mcf) String() string

type Parameter

type Parameter struct {
	Iterations      uint16 // log2 of the iteration count
	BlockSizeFactor uint8  // scrypt r parameter
	Parallelism     uint8  // scrypt p parameter
	Length          uint16 // output length in bytes, dkLen parameter
	SaltLength      uint16 // salt length in bytes
}

Parameter contains all required parameters for scrypth64

func DefaultParams

func DefaultParams() *Parameter

DefaultParams returns a prefilled *Parameter with default values. The defaults represent a 64MiByte memory consumption by scrypt per calculation and are intended for 2016 high performance datacenter equipment, not mobile gadgets. Uses a 512bit salt and 384bit digest.

func HighParams

func HighParams() *Parameter

HighParams returns a prefilled *Parameter with the recommended high security parameters from the scrypt paper. These represent 1GiByte of used memory per scrypt calculation.

func PaperParams

func PaperParams() *Parameter

PaperParams returns a prefilled *Parameter with the recommended values from the scrypt paper. These represent 16MiByte of used memory per scrypt calculation. Additional values are chosen with popular values.

Jump to

Keyboard shortcuts

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