vault

package
v0.0.0-...-a6f3d4c Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 21 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(ctx context.Context, host, port, token string, config Config, broker event.Broker, 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.

If config.KeyRefreshInterval is greater than 0, Vault starts to periodically purge the vault and write a new set of keys. Vault stops refreshing keyset when provided context is cancelled.

func (Vault) GetKeySet

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

GetKeySet returns a slice of keys present in the Vault.

func (Vault) GetRandom

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

GetRandom returns a random existing private key from the Vault.

Jump to

Keyboard shortcuts

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