vault

package
v0.0.0-...-913acc0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidKeyType        = errors.New("invalid key type")
	ErrInvalidKeyFormat      = errors.New("invalid key format")
	ErrAlgorithmNotSupported = errors.New("key's algorithm is not supported")
	ErrInvalidAlgorithm      = errors.New("key's algorithm is missing or invalid")
	ErrKeyMissing            = errors.New("key does not contain a private key")
	ErrFailedToParseKey      = errors.New("failed to parse key")
)

Functions

func DecodeECDSA

func DecodeECDSA(ecPem string) (*ecdsa.PrivateKey, error)

DecodeECDSA decodes EC PEM block and returns a non-nil err on failure.

func DecodeKey

func DecodeKey(algorithm entity.Algorithm, encodedKey string) (crypto.PrivateKey, entity.KeyEncodeFunc, error)

DecodeKey decodes provided key with specified algorithm and returns it along with a callback that should be used to encode the key to proto message format. If decode func for specified algorithm is not found it returns an ErrAlgorithmNotSupported. If the algorithm is not recognized it returns an ErrInvalidAlgorithm.

func DecodeRSA

func DecodeRSA(rsaPem string) (*rsa.PrivateKey, error)

DecodeRSA decodes RSA PEM block and returns a non-nil err on failure.

Types

type Config

type Config struct {
	// Path in the Vault that the client will mount on.
	MountPath          string
	KeyCount           int
	KeyRefreshInterval time.Duration
}

type Vault

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

func Make

func Make(host, port, token string, config Config, tracer trace.Tracer, logger logging.Logger) (Vault, error)

Make takes in a Token used to connect to Vault and returns a DB instance or a non nil error.

func (Vault) GetKeySet

func (db Vault) GetKeySet(ctx context.Context) ([]entity.Key, error)

GetKeySet returns a slice of keys present in the Vault.

func (Vault) GetRandom

func (db Vault) GetRandom(ctx context.Context) (entity.Key, error)

GetRandom returns a random existing private key from the Vault.

func (*Vault) Run

func (db *Vault) Run(ctx context.Context)

Run blocks until provided context is cancelled. When invoked Vault starts to periodically purge the vault and write a new set of keys in amount specified in the config.

Jump to

Keyboard shortcuts

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