auth

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

README

auth

Authentication Package

Documentation

Overview

Package auth is a authentication helper that supports multiple types of applications.

Index

Constants

View Source
const (
	// BcryptDefaultCost is the Bcrypt Default Cost where the performace is optimal
	BcryptDefaultCost int = bcrypt.DefaultCost
	// BcryptMaxCost is the Bcrypt Maximum Cost with Longest Time
	BcryptMaxCost int = bcrypt.MaxCost
	// BcryptMinCost is the Bcrypt Minimum Cost with Shortest time
	BcryptMinCost int = bcrypt.MinCost
)
View Source
const (
	// Pbkdf2DefaultRounds Default number of rounds to be used for PBKDF2
	Pbkdf2DefaultRounds int = 4096
	// Pbkdf2MaxRounds Maximum number of rounds to be used for PBKDF2
	Pbkdf2MaxRounds int = 8192
	// Pbkdf2MinRounds Minimum number of rounds to be used for PBKDF2
	Pbkdf2MinRounds int = 1024
)
View Source
const MethodPasswordHashBcrypt = "Password Hash using bcrypt"

MethodPasswordHashBcrypt defines password hash generation using bcrypt

View Source
const MethodPasswordHashPbkdf2HS256 = "Password Hash using pbkdf2 and HMAC-SHA256"

MethodPasswordHashPbkdf2HS256 defines password hash generation using pbkdf2 with HMAC-SHA256

View Source
const Pbkdf2RoundsSize int = 8

Pbkdf2RoundsSize is the Size of the Encoded number of rounds in a byte array

View Source
const Pbkdf2SaltSize int = 8

Pbkdf2SaltSize is the minimum recommended size of the Salt used for PBKDF2

Variables

View Source
var ErrNotImplemented = fmt.Errorf("error functionality not implemented yet")

ErrNotImplemented occurs when an Un-implemented feature is called on

View Source
var ErrNotInitialized = fmt.Errorf("error this construct is not initialized")

ErrNotInitialized occurs when an Authentication process or function tries to access an un-initialized data parameter or construct.

View Source
var ErrParameter = fmt.Errorf("error in supplied parameters")

ErrParameter occurs when there are issues with the supplied parameter in any function.

Functions

func CheckHS256 added in v0.0.4

func CheckHS256(input []byte, mac []byte, key []byte) error

CheckHS256 verifies the given MAC with supplied input

func CheckHS512 added in v0.0.4

func CheckHS512(input []byte, mac []byte, key []byte) error

CheckHS512 verifies the given MAC with supplied input

func CheckPbkdf2HS1 added in v0.0.5

func CheckPbkdf2HS1(key []byte, derivedKey []byte, salt []byte, rounds int) error

CheckPbkdf2HS1 check the PBKDF2 HMAC-SHA1 Key with an derived key

func CheckPbkdf2HS256 added in v0.0.5

func CheckPbkdf2HS256(key []byte, derivedKey []byte, salt []byte, rounds int) error

CheckPbkdf2HS256 check the PBKDF2 HMAC-SHA256 Key with an derived key

func CheckPbkdf2HS512 added in v0.0.5

func CheckPbkdf2HS512(key []byte, derivedKey []byte, salt []byte, rounds int) error

CheckPbkdf2HS512 check the PBKDF2 HMAC-SHA512 Key with an derived key

func FromBase64 added in v0.0.4

func FromBase64(input string) ([]byte, error)

FromBase64 converts a URL-Base64 encoded string back to a bytes array

func FromBase64Std added in v0.0.4

func FromBase64Std(input string) ([]byte, error)

FromBase64Std converts a Standard-Base64 encoded string back to a bytes array

func FromHex added in v0.0.4

func FromHex(input string) ([]byte, error)

FromHex converts a Hex encoded string back to a bytes array

func GetRandom added in v0.0.5

func GetRandom(size int) ([]byte, error)

GetRandom returns a cryptographically safe randome numbers byte array with the size specified

func HS256 added in v0.0.4

func HS256(data []byte, key []byte) ([]byte, error)

HS256 performs the HMAC-SHA256 operation on input data using the supplied key

func HS512 added in v0.0.4

func HS512(data []byte, key []byte) ([]byte, error)

HS512 performs the HMAC-SHA512 operation on input data using the supplied key

func Pbkdf2HS1 added in v0.0.5

func Pbkdf2HS1(key []byte, rounds int) (derivedKey []byte, salt []byte, err error)

Pbkdf2HS1 perform PBKDF2 Key Derivation using HMAC-SHA1

func Pbkdf2HS256 added in v0.0.5

func Pbkdf2HS256(key []byte, rounds int) (derivedKey []byte, salt []byte, err error)

Pbkdf2HS256 perform PBKDF2 Key Derivation using HMAC-SHA256

func Pbkdf2HS512 added in v0.0.5

func Pbkdf2HS512(key []byte, rounds int) (derivedKey []byte, salt []byte, err error)

Pbkdf2HS512 perform PBKDF2 Key Derivation using HMAC-SHA512

func SHA256 added in v0.0.4

func SHA256(data []byte) ([]byte, error)

SHA256 generates the SHA-256 Hash of the supplied data

func SHA512 added in v0.0.4

func SHA512(data []byte) ([]byte, error)

SHA512 generates the SHA-512 Hash of the supplied data

func ToBase64 added in v0.0.4

func ToBase64(data []byte) (string, error)

ToBase64 converts a bytes array into a URL-Base64 Encoded string

func ToBase64Std added in v0.0.4

func ToBase64Std(data []byte) (string, error)

ToBase64Std converts a bytes array into a Standard-Base64 Encoded string

func ToHex added in v0.0.4

func ToHex(data []byte) (string, error)

ToHex converts a bytes array into a Hex Encoded string

Types

type Auth

type Auth interface {

	// Create function generates the Authentication Entity by processing
	// incoming data and the specific 'bias'.
	Create(data []byte, bias interface{}) ([]byte, error)

	// Verify function checks the Authentication Entity by processing
	// it with the optional incoming 'bias'. It also recovers the original
	// 'data' and 'bias' used to create the Authentication Entity.
	Verify(value []byte, bias interface{}) ([]byte, interface{}, error)

	// Set function configures the Authentication Entity creation and
	// verification process. It also accepts the static "Key" that needs
	// to be employed while processing the Authentication Entity.
	Set(method string, key interface{}) error
}

Auth is the generic interface that would be implemented by the various authentication algorithms and classifications.

The term "Authentication Entity" refers to a token, pass, or a Unique piece of information that provides Identity, and Authorization status of the bearer.

func NewPasswordHash added in v0.0.2

func NewPasswordHash(method string, key interface{}) (Auth, error)

NewPasswordHash Configures the respective password Hashing algorithm and returns the instance which implements the Auth Interface

Jump to

Keyboard shortcuts

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