yasec

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package yasec helps to keep secrets in config files as secret as possible.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func PromptNewPassword

func PromptNewPassword(p1, p2 string) (*memguard.Enclave, error)

func PromptPassword

func PromptPassword(p string) (*memguard.Enclave, error)

func ReadPassword

func ReadPassword() (*memguard.Enclave, error)

Types

type Config

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

Config holds the master password that is used to decrypt a Secret when it opened for actual use.

var DefaultConfig Config

DefaultConfig config is used to access a Secret when that secret has no explicit Config.

func NewConfig

func NewConfig(key *memguard.Enclave) Config

func (*Config) Set

func (cfg *Config) Set(key *memguard.Enclave)

func (*Config) SetFromPrompt

func (cfg *Config) SetFromPrompt(text string, salt []byte) error

func (*Config) SetFromUnixSocket

func (cfg *Config) SetFromUnixSocket(path string, salt []byte) error

func (*Config) SetPassword

func (cfg *Config) SetPassword(passwd, salt []byte)

func (*Config) SetPasswordFrom

func (cfg *Config) SetPasswordFrom(pwr Passworder, salt []byte) error

func (*Config) SetPasswordString

func (cfg *Config) SetPasswordString(passwd string, salt []byte)

type FDPassword

type FDPassword uintptr

func (FDPassword) Password

func (pw FDPassword) Password() (*memguard.Enclave, error)

type PasswordPrompt

type PasswordPrompt string

PasswordPrompt is a Passworder that reads a password directly from a terminal without echoing the user input. One can use e.g. term.IsTerminal() to check if password can be provided this way.

func (PasswordPrompt) Password

func (pw PasswordPrompt) Password() (*memguard.Enclave, error)

type Passworder

type Passworder interface {
	Password() (*memguard.Enclave, error)
}

Passworders are used to supply a master password for Config (see also Config.SetPasswordFrom).

type PasswordsDiffer

type PasswordsDiffer struct{}

func (PasswordsDiffer) Error

func (PasswordsDiffer) Error() string

type Secret

type Secret struct {
	Config *Config
	// contains filtered or unexported fields
}
Example
key := memguard.NewBufferFromBytes([]byte{
	0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
})
cfg := NewConfig(key.Seal())
secret := Secret{Config: &cfg}
data := must.Ret(memguard.NewBufferFromEntireReader(strings.NewReader("foo bar baz")))
secret.Set(data)
data.Destroy()

data = must.Ret(secret.Open())
defer data.Destroy()
fmt.Println(data.String())
Output:

foo bar baz

func (Secret) Empty added in v0.6.1

func (sec Secret) Empty() bool

func (Secret) Equal

func (sec Secret) Equal(data []byte) (bool, error)

func (Secret) EqualString

func (sec Secret) EqualString(s string) (bool, error)

func (Secret) MarshalBinary

func (sec Secret) MarshalBinary() (data []byte, err error)

func (Secret) MarshalText

func (sec Secret) MarshalText() (text []byte, err error)

func (*Secret) MergeDaQ

func (sec *Secret) MergeDaQ(m *daq.Merge, add any) error

func (Secret) Open

func (sec Secret) Open() (*memguard.LockedBuffer, error)

func (Secret) Protected added in v0.6.1

func (sec Secret) Protected() bool

func (*Secret) Set

func (sec *Secret) Set(buf *memguard.LockedBuffer) (err error)

func (*Secret) UnmarshalBinary

func (sec *Secret) UnmarshalBinary(data []byte) error

func (*Secret) UnmarshalText

func (sec *Secret) UnmarshalText(text []byte) error

type UnixSocketPassword

type UnixSocketPassword string

UnixSocketPassword is a Passworder that reads the password from a temporary unix domain socket that is closed and deleted after the password has been read. Note that the unix domain socket can be intercepted by other processes which also it vulnerable for a short period of time.

For example, if you start a programm with nohup, you can use this method to provide the password without including it in argv[] or envp[] (C style). Both are considered insecure.

func (UnixSocketPassword) Password

func (pw UnixSocketPassword) Password() (*memguard.Enclave, error)

Jump to

Keyboard shortcuts

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