password

package
v0.0.0-...-30d1bac Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSCRAMPasswordInvalid is returned when the password attributes are invalid
	ErrSCRAMPasswordInvalid = errors.New(`invalid password attributes. must provide "password"`)
	// ErrSCRAMSaltLengthInvalid is returned when the salt length is less than 1
	ErrSCRAMSaltLengthInvalid = errors.New(`salt length must be at least 1`)
)
View Source
var ErrMD5PasswordInvalid = errors.New(`invalid password attributes. must provide "username" and "password"`)

ErrMD5PasswordInvalid is returned when the password attributes are invalid

View Source
var ErrPasswordType = errors.New("password type does not exist")

ErrPasswordType is returned when a password type does not exist

Functions

This section is empty.

Types

type IvoryPassword

type IvoryPassword interface {
	// Build transforms any plaintext or other attributes that are provided by
	// the interface implementor and returns a password. If an error occurs in the
	// building process, it is returned.
	//
	// If the build does error, return an empty string
	Build() (string, error)
}

IvoryPassword is the interface that defines the methods required to build a password for IvorySQL in a desired format (e.g. MD5)

func NewIvoryPassword

func NewIvoryPassword(passwordType PasswordType, username, password string) (IvoryPassword, error)

NewIvoryPassword accepts a type of password (e.g. md5) which is used to select the correct generation interface, as well as a username and password and returns the appropriate interface

An error is returned if the proper password generator cannot be found

type MD5Password

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

MD5Password implements the IvoryPassword interface for hashing passwords using the IvorySQL MD5 method

func NewMD5Password

func NewMD5Password(username, password string) *MD5Password

NewMD5Password constructs a new MD5Password struct

func (*MD5Password) Build

func (m *MD5Password) Build() (string, error)

Build creates the MD5 password format for IvorySQL which resembles "md5" + md5("password" + "username")

type PasswordType

type PasswordType int

PasswordType helps to specify the type of password method (e.g. md5) to use

const (
	// MD5 refers to the MD5Password method
	MD5 PasswordType = iota
	SCRAM
)

The following constants are used to aid in the select of the types of IvorySQL password generators

type SCRAMPassword

type SCRAMPassword struct {
	// Iterations is the number of iterations to run the PBKDF2 algorithm when
	// generating the hashed salted password. This defaults to 4096, which is the
	// IvorySQL default
	Iterations int
	// SaltLength is the length of the generated salt that is used as part of the
	// PBKDF2 algorithm
	SaltLength int
	// contains filtered or unexported fields
}

SCRAMPassword contains the building blocks to build a IvorySQL SCRAM verifier. Implements the IvoryPassword interface

func NewSCRAMPassword

func NewSCRAMPassword(password string) *SCRAMPassword

NewSCRAMPassword constructs a new SCRAMPassword struct with sane defaults

func (*SCRAMPassword) Build

func (s *SCRAMPassword) Build() (string, error)

Build creates the SCRAM verifier, which follows the methods defined in the IvorySQL source, i.e.

https://git.ivorysql.org/gitweb/?p=ivorysql.git;a=blob;f=src/include/common/scram-common.h

Jump to

Keyboard shortcuts

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