vault

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrVaultNotInitialized = errors.New("vault is not properly initialized")
)

Functions

This section is empty.

Types

type AesGcmEncryption

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

func NewAesGcmEncryption

func NewAesGcmEncryption(deriver KeyDeriver) *AesGcmEncryption

func (AesGcmEncryption) Decrypt

func (a AesGcmEncryption) Decrypt(cipherText []byte, passphrase string, salt, nonce []byte) (plainText []byte, err error)

func (AesGcmEncryption) Encrypt

func (a AesGcmEncryption) Encrypt(plainText []byte, passphrase string) (cipherText, salt, nonce []byte, err error)

type Decrypter

type Decrypter interface {
	Decrypt(cipherText []byte, passphrase string, salt, nonce []byte) (plainText []byte, err error)
}

type Encrypter

type Encrypter interface {
	Encrypt(plainText []byte, passphrase string) (cipherText, salt, nonce []byte, err error)
}

type Encryption

type Encryption interface {
	Encrypter
	Decrypter
}

type Entry

type Entry struct {
	Value []byte
	Salt  []byte
	Nonce []byte
}

func EntryFromText

func EntryFromText(txt string) (e Entry, err error)

func (Entry) Decrypt

func (e Entry) Decrypt(decrypter Decrypter, passphrase string) ([]byte, error)

func (Entry) MarshalText

func (e Entry) MarshalText() string

type InitOption

type InitOption interface {
	// contains filtered or unexported methods
}

func WithEncryption

func WithEncryption(encryption Encryption) InitOption

func WithLoadFromPath

func WithLoadFromPath(path string) InitOption

func WithPassphrase

func WithPassphrase(passphrase string) InitOption

func WithPassphraseFile

func WithPassphraseFile(path string) InitOption

type KeyDeriver

type KeyDeriver interface {
	DeriveKey(passphrase string, existingSalt []byte) (key, salt []byte)
}

func Pbkdf2Deriver

func Pbkdf2Deriver() KeyDeriver

type KeyDeriverFunc

type KeyDeriverFunc func(passphrase string, existingSalt []byte) (key, salt []byte)

func (KeyDeriverFunc) DeriveKey

func (f KeyDeriverFunc) DeriveKey(passphrase string, existingSalt []byte) (key, salt []byte)

type Vault

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

func NewVault

func NewVault(opts ...InitOption) (*Vault, error)

func (*Vault) GetValue

func (v *Vault) GetValue(entryKey string) ([]byte, error)

func (*Vault) Keys

func (v *Vault) Keys() []string

func (*Vault) MarshalJSON

func (v *Vault) MarshalJSON() ([]byte, error)

func (*Vault) RemoveValue

func (v *Vault) RemoveValue(entryKey string)

func (*Vault) SetValue

func (v *Vault) SetValue(entryKey string, plainText []byte) error

func (*Vault) UnmarshalJSON

func (v *Vault) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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