keyring

package
v0.0.0-...-820a931 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFieldRequired = errors.New("field required")
)

Functions

func GenerateEncodedNACLKeyPair

func GenerateEncodedNACLKeyPair() (marshaledEncryptorKey []byte, marshaledDecryptorKey []byte, err error)

GenerateEncodedNACLKeyPair returns to byte slice containing the encoded values of the couple of keypairs freshly generated.

func GenerateKeyPair

func GenerateKeyPair(r io.Reader) (encryptorKey *NACLKey, decryptorKey *NACLKey, err error)

GenerateKeyPair returns a couple keypairs that can be used for asymmetric encryption/decryption using nacl crypto box API.

func MarshalNACLKey

func MarshalNACLKey(key *NACLKey) []byte

MarshalNACLKey takes a key and returns its encoded version.

Types

type Config

type Config struct {
	EncryptorKeyPath string `mapstructure:"credentials_encryptor_key"`
	DecryptorKeyPath string `mapstructure:"credentials_decryptor_key"`
}

Config used to setup a Keyring service.

type Keyring

type Keyring interface {
	// CredentialsEncryptorKey returns the key used to encrypt credentials values,
	// stored in accounts.
	CredentialsEncryptorKey() *NACLKey
	// CredentialsDecryptorKey returns the key used to decrypt credentials values,
	// stored in accounts.
	CredentialsDecryptorKey() *NACLKey
}

Keyring handle the encryption/decryption keys

func NewFromConfig

func NewFromConfig(conf Config) (Keyring, error)

type NACLKey

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

NACLKey contains a NACL crypto box keypair.

func UnmarshalNACLKey

func UnmarshalNACLKey(marshaledKey []byte) (key *NACLKey, err error)

UnmarshalNACLKey takes and encoded value of a keypair and unmarshal its value, returning the associated key.

func (*NACLKey) PrivateKey

func (n *NACLKey) PrivateKey() *[32]byte

PrivateKey returns the private part of the keypair.

func (*NACLKey) PublicKey

func (n *NACLKey) PublicKey() *[32]byte

PublicKey returns the public part of the keypair.

type Service

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

Service contains security keys used for various encryption or signing of critical assets.

func NewService

func NewService(conf Config) (*Service, error)

NewService instantiate a new Keyring.

func (*Service) CredentialsDecryptorKey

func (s *Service) CredentialsDecryptorKey() *NACLKey

func (*Service) CredentialsEncryptorKey

func (s *Service) CredentialsEncryptorKey() *NACLKey

type Stub

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

Stub is a minimal *UNSECURE* implementation of Keyring.

As the credentials should remain the same between several executions of the stack, we are using some credentials generated with a seed defined at build time. It is obviously not a good idea from a security point of view, and it should not be used to store sensible data. This implem is not safe and should never be used in production.

func NewStub

func NewStub() (*Stub, error)

NewStub instantiate a new Stub.

func (*Stub) CredentialsDecryptorKey

func (s *Stub) CredentialsDecryptorKey() *NACLKey

func (*Stub) CredentialsEncryptorKey

func (s *Stub) CredentialsEncryptorKey() *NACLKey

Jump to

Keyboard shortcuts

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