salt

package
Version: v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: MPL-2.0 Imports: 10 Imported by: 19

Documentation

Index

Constants

View Source
const (
	// DefaultLocation is the path in the view we store our key salt
	// if no other path is provided.
	DefaultLocation = "salt"
)

Variables

This section is empty.

Functions

func HMACIdentifiedValue

func HMACIdentifiedValue(salt, val, hmacType string, hashFunc func() hash.Hash) string

func HMACValue

func HMACValue(salt, val string, hashFunc func() hash.Hash) string

func SHA1Hash

func SHA1Hash(inp []byte) []byte

SHA1Hash returns the SHA1 of the input

func SHA256Hash

func SHA256Hash(inp []byte) []byte

SHA256Hash returns the SHA256 of the input

func SaltID

func SaltID(salt, id string, hash HashFunc) string

SaltID is used to apply a salt and hash function to an ID to make sure it is not reversible

Types

type Config

type Config struct {
	// Location is the path in the storage backend for the
	// salt. Uses DefaultLocation if not specified.
	Location string

	// HashFunc is the hashing function to use for salting.
	// Defaults to SHA1 if not provided.
	HashFunc HashFunc

	// HMAC allows specification of a hash function to use for
	// the HMAC helpers
	HMAC func() hash.Hash

	// String prepended to HMAC strings for identification.
	// Required if using HMAC
	HMACType string
}

Config is used to parameterize the Salt

type HashFunc

type HashFunc func([]byte) []byte

type Salt

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

Salt is used to manage a persistent salt key which is used to hash values. This allows keys to be generated and recovered using the global salt. Primarily, this allows paths in the storage backend to be obfuscated if they may contain sensitive information.

func NewNonpersistentSalt added in v0.2.0

func NewNonpersistentSalt() *Salt

NewNonpersistentSalt creates a new salt with default configuration and no storage usage.

func NewSalt

func NewSalt(ctx context.Context, view logical.Storage, config *Config) (*Salt, error)

NewSalt creates a new salt based on the configuration

func (*Salt) DidGenerate

func (s *Salt) DidGenerate() bool

DidGenerate returns true if the underlying salt value was generated on initialization.

func (*Salt) GetHMAC

func (s *Salt) GetHMAC(data string) string

GetHMAC is used to apply a salt and hash function to data to make sure it is not reversible, with an additional HMAC

func (*Salt) GetIdentifiedHMAC

func (s *Salt) GetIdentifiedHMAC(data string) string

GetIdentifiedHMAC is used to apply a salt and hash function to data to make sure it is not reversible, with an additional HMAC, and ID prepended

func (*Salt) SaltID

func (s *Salt) SaltID(id string) string

SaltID is used to apply a salt and hash function to an ID to make sure it is not reversible

func (*Salt) SaltIDHashFunc

func (s *Salt) SaltIDHashFunc(id string, hashFunc HashFunc) string

SaltIDHashFunc uses the supplied hash function instead of the configured hash func in the salt.

Source Files

Jump to

Keyboard shortcuts

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