vault

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package vault implements Brief's password manager.

Index

Constants

View Source
const DefaultTrust = BriefTrustD015c957

MUST be changed when cryptographic methods lose their trustworthiness

Variables

View Source
var ErrBriefTrustD015c957 = errors.New(string(BriefTrustD015c957))
View Source
var ErrEscapingPlaintext = errors.New("escaping plaintext")
View Source
var ErrInsufficientEntropy = errors.New("insufficient entropy")
View Source
var ErrNoCrypter = errors.New("no crypter")
View Source
var ErrPassword errPassword
View Source
var ErrUnknownTrust = errors.New("unknown trust")

Functions

This section is empty.

Types

type Bytes

type Bytes []byte

Bytes represents a base64-marshallable slice of bytes.

func (Bytes) MarshalText

func (b Bytes) MarshalText() ([]byte, error)

func (*Bytes) UnmarshalText

func (b *Bytes) UnmarshalText(text []byte) error

type Ciphertext

type Ciphertext []byte

Ciphertext represents a slice of bytes whose public knowledge is permissible. It thus base64-text-marshals itself.

func ReadCiphertext

func ReadCiphertext(passwordsource PasswordSource, crypter Crypter, prompt string) (Ciphertext, error)

ReadCiphertext reads sensitive information in and encrypts it using crypter.

Once: func Console(crypter Crypter, prompt string) (Ciphertext, error) {

func (Ciphertext) MarshalText

func (ct Ciphertext) MarshalText() ([]byte, error)

func (*Ciphertext) UnmarshalText

func (ct *Ciphertext) UnmarshalText(text []byte) error

type Crypter

type Crypter interface {
	// Encrypt encrypts plaintext into ciphertext.
	// Encrypt MUST NEITHER passed-in NOR passed-out values.
	// Encrypt MUST fail if the system's entropy is non-sufficient.
	Encrypt(Plaintext) (Ciphertext, error)

	// Decrypt decrypts ciphertext into plaintext.
	// Decrypt MUST NEITHER passed-in NOR passed-out values.
	// Decrypt MUST fail if the system's entropy is non-sufficient.
	Decrypt(Ciphertext) (Plaintext, error)
}

type Password

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

Password represents a vault-internal password. Password is designed to be opaque as to make it hard to in good faith leak a password.

func ReadPassword

func ReadPassword(passwordsource PasswordSource, prompt string) (Password, error)

Once: ConsolePassword

type PasswordSource

type PasswordSource func(prompt string) (Password, error)

func Console

func Console() PasswordSource

TODO expunge (implementations should use their *World's PasswordSource and no one should need to call this

func HideSource

func HideSource(source func(prompt string) ([]byte, error)) PasswordSource

TODO ugly name?

Used primarily for testing.

func OSPasswordSource

func OSPasswordSource(stdin interface{ Fd() uintptr }, stderr io.Writer) PasswordSource

type Plaintext

type Plaintext []byte

Plaintext represents a slice of bytes whose public knowledge is a breach of confidentiality. It thus disallows text marshalling.

func (Plaintext) MarshalText

func (_ Plaintext) MarshalText() ([]byte, error)

func (Plaintext) UnmarshalText

func (_ Plaintext) UnmarshalText(text []byte) error

type RecryptFunc

type RecryptFunc = func(oldciphertext Ciphertext) (newciphertext Ciphertext, err error)

type Trust

type Trust string
const (
	BriefTrustD015c957 Trust = "brief.trust.d015c957"
)

type Vault

type Vault struct {
	XMLName xml.Name `xml:"vault"`

	Trust Trust `xml:"trust"`

	Salt Bytes `xml:"salt"`

	ProofPlaintext  Bytes      `xml:"proof-plaintext"`
	ProofCiphertext Ciphertext `xml:"proof-ciphertext"`
}

func NewVault

func NewVault(trust Trust, secret any) (*Vault, error)

func NewVault_

func NewVault_(passwordsource PasswordSource, trust Trust) (*Vault, error)

passwordsource may be nil

func (*Vault) Clone

func (oldv *Vault) Clone() *Vault

Vault.Clone returns a deep clone.

func (*Vault) Crypter

func (v *Vault) Crypter(secret any) (Crypter, error)

func (*Vault) Crypter_

func (v *Vault) Crypter_(passwordsource PasswordSource) (Crypter, error)

Once: func (v *Vault) ConsolePassword() (Crypter, error) {

func (*Vault) Fixup

func (v *Vault) Fixup(secret any) error

secret may be nil, in which case Vault.ProofCiphertext may become stale.

func (*Vault) Recrypt

func (oldv *Vault) Recrypt(oldsecret any, newtrust Trust, newsecret any) (*Vault, RecryptFunc, error)

Jump to

Keyboard shortcuts

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