crypto

package
v4.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2017 License: GPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const DefaultMasterPasswordSeed = common.DefaultMasterPasswordSeed

DefaultMasterPasswordSeed is the default seed and allows it to be compatible with http://masterpasswordapp.com/algorithm.html

View Source
const MasterPasswordTypes = "basic, long, maximum, medium, name, phrase, pin, short"

MasterPasswordTypes is for listing the current supported password types.

Default: long
View Source
const MpwSeries = "2.6"

MpwSeries denotes the mpw cli client version compatibility.

Variables

View Source
var (
	Dbg  = debug.NewDebug().Dbg
	DbgO = debug.NewDebug().DbgO
)

Debugging helpers

View Source
var (
	ErrPasswordPurposeEmpty             = errors.New("Site password purpose must be set")
	ErrPasswordPurposeInvalid           = errors.New("Invalid site password purpose")
	ErrPasswordPurposeCounterOutOfRange = errors.New("Site password purpose is using an out of range counter")
)

PasswordPurpose exported errors

View Source
var (
	ErrCounter                 = errors.New("site password counter must be >= 1")
	ErrFullnameEmpty           = errors.New("Site fullname must be set")
	ErrMasterPasswordSeedEmpty = errors.New("MasterPassword seed must be set")
	ErrPasswordEmpty           = errors.New("Site password must be set")
	ErrPasswordTypeEmpty       = errors.New("Password type must be set")
	ErrPasswordTypeInvalid     = errors.New("Password type is invalid")
	ErrSiteEmpty               = errors.New("Site name must be set")
)

Validation exported errors

Functions

func MasterPassword

func MasterPassword(mpwseed, passwordType, passwordPurpose, fullname, password, site string, counter uint32) (string, error)

MasterPassword returns a derived password according to: http://masterpasswordapp.com/algorithm.html

Valid PasswordTypes: basic, long, maximum, medium, name, phrase, pin, short

func ValidateCounter

func ValidateCounter(counter uint32) error

ValidateCounter validates that the site counter value is >= 1

func ValidateFullname

func ValidateFullname(fullname string) error

ValidateFullname validates that fullname is not empty

func ValidateMasterPasswordSeed

func ValidateMasterPasswordSeed(seed string) error

ValidateMasterPasswordSeed validates that seed is not empty

func ValidatePassword

func ValidatePassword(password string) error

ValidatePassword verifies that password is not empty

func ValidatePasswordPurpose

func ValidatePasswordPurpose(purpose string) error

ValidatePasswordPurpose will test if given purpose is valid

func ValidatePasswordType

func ValidatePasswordType(passwordType string) error

ValidatePasswordType verifies that passwordType is not empty and a valid type

func ValidateSite

func ValidateSite(site string) error

ValidateSite validates that site is not empty

Types

type MasterPW

type MasterPW struct {
	Config *config.MPConfig
	// contains filtered or unexported fields
}

MasterPW contains all relevant items for MasterPassword to act upon.

func NewMasterPassword

func NewMasterPassword() *MasterPW

NewMasterPassword returns a new empty MasterPW struct

func (*MasterPW) GetPasswordTypes

func (m *MasterPW) GetPasswordTypes() []string

GetPasswordTypes returns a sorted list of valid password types

func (*MasterPW) MasterPassword

func (mpw *MasterPW) MasterPassword() (string, error)

MasterPassword returns a derived password according to: http://masterpasswordapp.com/algorithm.html

Valid PasswordTypes: basic, long, maximum, medium, name, phrase, pin, short

func (*MasterPW) MergeConfig

func (mpw *MasterPW) MergeConfig() error

MergeConfig will transfer and validate data from Config to MasterPW for any nil values.

func (*MasterPW) MergeConfigEX

func (mpw *MasterPW) MergeConfigEX(c *config.MPConfig) error

MergeConfigEX will transfer and validate data from given MPConfig to MasterPW for any nil values.

func (*MasterPW) SetCounter

func (mpw *MasterPW) SetCounter(counter uint32) (err error)

SetCounter is a setter for MasterPW.counter

func (*MasterPW) SetFullname

func (mpw *MasterPW) SetFullname(fullname string) (err error)

SetFullname is a setter for MasterPW.fullname

func (*MasterPW) SetMasterPasswordSeed

func (mpw *MasterPW) SetMasterPasswordSeed(seed string) (err error)

SetMasterPasswordSeed is a setter for MasterPW.masterPasswordSeed

func (*MasterPW) SetPassword

func (mpw *MasterPW) SetPassword(password string) (err error)

SetPassword is a setter for MasterPW.password

func (*MasterPW) SetPasswordPurpose

func (mpw *MasterPW) SetPasswordPurpose(purpose string) (err error)

SetPasswordPurpose sets the MasterPassword's generated password purpose

func (*MasterPW) SetPasswordType

func (mpw *MasterPW) SetPasswordType(pwtype string) (err error)

SetPasswordType is a setter for MasterPW.passwordType

func (*MasterPW) SetSite

func (mpw *MasterPW) SetSite(site string) (err error)

SetSite is a setter for MasterPW.site

func (*MasterPW) Validate

func (mpw *MasterPW) Validate() error

Validate ensures that MasterPW is ready for MasterPassword().

  1. masterPasswordSeed
  2. passwordType
  3. passwordPurpose
  4. fullname
  5. password
  6. site
  7. counter

func (*MasterPW) ValidatePasswordPurpose

func (mpw *MasterPW) ValidatePasswordPurpose() error

ValidatePasswordPurpose will test if MasterPW password purpose is valid

type PasswordPurpose

type PasswordPurpose int

PasswordPurpose allows for different generated passwords for same Site depending on its intended purpose.

Given the same {fullname, password, site}, specifying a different 'purpose' will perturb the final generated password in a consistent manner.

  1. *Unset*

  2. Authentication (counter=N)

  3. Identification (counter=1)

  4. Recovery (counter=1)

    NOTE: Authentication is perturbed by counter, whereas the others are not.

const (
	PasswordPurposeUnSet PasswordPurpose = iota
	PasswordPurposeAuthentication
	PasswordPurposeIdentification
	PasswordPurposeRecovery
)

PasswordPurpose lookup tokens

func PasswordPurposeToToken

func PasswordPurposeToToken(purpose string) (PasswordPurpose, error)

PasswordPurposeToToken returns the const token associated with given purpose

func (*PasswordPurpose) String

func (pp *PasswordPurpose) String() string

func (*PasswordPurpose) Validate

func (pp *PasswordPurpose) Validate() error

Validate will test if password purpose is valid

Jump to

Keyboard shortcuts

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