hush

package module
v0.0.0-...-55806de Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2018 License: Unlicense Imports: 23 Imported by: 0

README

NAME
    hush - tiny password manager

SYNOPSIS
    hush [command [arguments]]

INSTALLATION
    go install github.com/mndrix/hush/...

DESCRIPTION
    hush is a password manager with a small, understandable code base.
    Your secrets are stored in a tree with encrypted leaves.  You can
    organize the tree in whatever hierarchy you prefer.

    The hush file (in $HOME/.hush by default) is a plaintext file with
    a simple format reminiscent of YAML.  It's designed to be kept
    under version control, although that's not necessary.  The file
    also contains a cryptographic checksum to avoid unauthorized
    modifications.

COMMANDS
    This section contains a list of commands supported by hush. The
    command name should be the second argument on the command line when
    invoking hush.

    export
        Exports the decrypted contents of your hush file to stdout.
        Each line represents a leaf and the path to that leaf. Each
        line is split into two columns, separated by a tab character.
        The first column is a slash-separated path. The second column
        is the leaf's plaintext.

        See also: import command

    help
        Displays this help text.

    import
        Imports plaintext paths and leaves from stdin into your hush
        file.  The input format is the same as that generated by
        the export command.

        See also: export command

    init
        Initializes a new hush file after prompting the user to
        create a password.  This command must be run before most of
        the other commands can be run.

    ls [pattern]
        Lists all decrypted subtrees matching 'pattern'.  If 'pattern'
        is omitted, lists the entire tree.

        See also: PATTERNS

    rm path [path [path [...]]]
        Removes each path, and its subtrees, from the hush file.

    set path value
        Sets the leaf at 'path' to have 'value'.  The value is stored
        encrypted in the hush file.  The path is not encrypted.

        If value is '-' then the leaf's value is read from stdin.

PATTERNS

    A pattern matches paths within the tree.  A pattern is first split
    on '/' to generate subpatterns.  Each subpattern describes a
    descent one level deeper into the tree.  At each level, a
    subpattern matches all local paths which contain the subpattern as
    a substring.

    For example:

        $ hush ls
        paypal.com:
            personal:
                password: secret
            work:
                password: 123456
        bitpay.com:
            work:
                password: 42 bitcoins

        $ hush ls pay/work
        paypal.com:
            work:
                password: 123456
        bitpay.com:
            work:
                password: 42 bitcoins


ENVIRONMENT VARIABLES
    This section describes environment variables which can be used to
    change the default behavior of hush.

    HUSH_ASKPASS
        When hush needs to request a password, it runs the script
        pointed to by this variable.  The script is invoked with a
        single argument: the text to use in the prompt.  The script's
        stdout is used as the password.

        If you get tired of typing your password repeatedly, you can
        set this variable to a script that caches your password.

        If HUSH_ASKPASS is missing, hush prompts on the user's
        terminal.

    HUSH_FILE
        Set this variable to the absolute path of your hush file.
        The default, if empty, is $HOME/.hush

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AskPassword

func AskPassword(w io.Writer, prompt string) ([]byte, error)

AskPassword asks the user for a password by presenting the given prompt. Users can point HUSH_ASKPASS environment at a script of their choice to change how passwords are collected. In either case, the provided password is returned along with any errors.

By default, the prompt is displayed on w and the password is read, without echo, from the terminal.

func CmdExport

func CmdExport(w io.Writer, t *Tree) error

CmdExport writes tree t to w in a tab-separated format suitable for use with "hush import" and scripting.

This function implements "hush export".

func CmdHelp

func CmdHelp(w io.Writer)

func CmdImport

func CmdImport(r io.Reader, tree *Tree) ([]string, error)

CmdImport reads tab-separated lines from r adding the path-value pairs to tree. Returns a slice of warnings, if any.

This function implements "hush import".

func CmdInit

func CmdInit(w io.Writer, input *os.File) error

CmdInit initializes the user's hush file, if it does not exist. Informative user messages are written to w. User input, if needed, is taken from input.

This function implements "hush init"

func CmdLs

func CmdLs(w io.Writer, tree *Tree, pattern string) error

CmdLs prints to w that portion of tree which matches pattern.

This function implements "hush ls"

func CmdRm

func CmdRm(tree *Tree, paths []Path) error

CmdRm removes paths from tree.

This function implements "hush rm"

func CmdSet

func CmdSet(w io.Writer, tree *Tree, p Path, v *Value) error

CmdSet sets the value for a given path in tree.

This function implements "hush set"

func Home

func Home() (string, error)

Home returns the user's home directory.

func HushPath

func HushPath() (string, error)

HushPath returns the filename of this user's hush file, whether it exists or not. If the file doesn't exist, it also returns an error for which os.IsNotExist() is true.

Any symlinks along the way are resolved until a concrete file is found.

func Main

func Main()

Main implements the main() function of the hush command line tool.

Types

type Branch

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

type Path

type Path string

Path represents the sequence of keys needed to reach a particular node with a Tree.

func NewPath

func NewPath(p string) Path

NewPath returns a path representing the given slash-separated path.

func (Path) AsCrumbs

func (p Path) AsCrumbs() []string

AsCrumbs returns this path as a slice of separate path components.

func (Path) HasDescendant

func (p Path) HasDescendant(d Path) bool

HasDescendant returns true if p is the parent of d.

func (Path) IsChecksum

func (p Path) IsChecksum() bool

IsChecksum returns true if p is the path that stores the tree's HMAC.

func (Path) IsConfiguration

func (p Path) IsConfiguration() bool

IsConfiguration returns true if p is a path describing a portion of the tree which belongs to a hush configuration.

func (Path) IsEncryptionKey

func (p Path) IsEncryptionKey() bool

IsEncryptionKey returns true if p is the path that stores the user's encryption key.

func (Path) IsMacKey

func (p Path) IsMacKey() bool

IsMacKey returns true if p is the path that stores the user's MAC key.

func (Path) IsPublic

func (p Path) IsPublic() bool

IsPublic returns true if p is a path whose value must be publicly visible.

func (Path) Parent

func (p Path) Parent() Path

Parent returns a path pointing to the parent of this path. If the path has no parent, returns itself.

func (Path) String

func (p Path) String() string

String returns this path in canonical format.

type Privacy

type Privacy int8

Privacy represents the desired level of privacy for a value. Either public or private.

const (
	Public Privacy
	Private
)

type Tree

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

func LoadTree

func LoadTree() (*Tree, error)

func (*Tree) Checksum

func (t *Tree) Checksum() []byte

Checksum returns a cryptographic message authentication code for this tree.

func (*Tree) Decrypt

func (tree *Tree) Decrypt() *Tree

Decrypt returns a copy of this tree with all leaves decrypted.

func (*Tree) Delete

func (t *Tree) Delete(paths ...Path) int

Delete removes a path and all its descendants from the tree. Returns the number of branches removed.

func (*Tree) Empty

func (t *Tree) Empty() *Tree

Empty returns a copy of this tree with all the keys and values removed. It retains any other data associated with this tree.

func (*Tree) Encode

func (tree *Tree) Encode() *Tree

Encode returns a copy of this tree with all leaves encoded into base64.

func (*Tree) Encrypt

func (tree *Tree) Encrypt() *Tree

Encrypt returns a copy of this tree with all leaves encrypted.

func (*Tree) Filter

func (t *Tree) Filter(pattern string) *Tree

Filter returns a subtree whose branches all match the given pattern.

func (*Tree) Len

func (t *Tree) Len() int

func (*Tree) Less

func (t *Tree) Less(i, j int) bool

func (*Tree) Print

func (tree *Tree) Print(w io.Writer) error

Print displays a tree for human consumption.

func (*Tree) Save

func (tree *Tree) Save() error

Save stores a tree to disk for permanent, private archival.

func (*Tree) SetPassphrase

func (t *Tree) SetPassphrase(password []byte) error

SetPassphrase sets the password that's used for performing encryption and decryption.

func (*Tree) Sort

func (t *Tree) Sort()

Sort sorts the tree in place and defragments any deleted branches.

func (*Tree) Swap

func (t *Tree) Swap(i, j int)

type Value

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

Value represents a string contained in the leaf of a Tree.

func CaptureValue

func CaptureValue(s string) (*Value, error)

CaptureValue converts a command line argument into a value. It handles sugar such as "-" (meaning "capture a value from stdin"). The captured value is assumed to be private.

func NewCiphertext

func NewCiphertext(ciphertext []byte, privacy Privacy) *Value

NewCiphertext returns a new value representing the given plaintext.

func NewEncoded

func NewEncoded(encoded string, privacy Privacy) *Value

NewEncoded returns a new value representing an encoded text. The privacy determines whether it's interpreted as an encoded plaintext or ciphertext.

func NewPlaintext

func NewPlaintext(plaintext []byte, privacy Privacy) *Value

NewPlaintext returns a new value representing the given plaintext.

func (*Value) Ciphertext

func (v *Value) Ciphertext(key []byte) *Value

Ciphertext returns a version of this value that's been encrypted with the given key.

func (*Value) Decode

func (v *Value) Decode() (*Value, error)

Decode returns a version of this value that's had all base64 encoding removed. It's a noop if the value has already been decoded.

func (*Value) Encode

func (v *Value) Encode() *Value

Encode returns a version of this value that's been wrapped in base64 encoding. It's a noop if the value has already been encoded.

func (*Value) Plaintext

func (v *Value) Plaintext(key []byte) (*Value, error)

Plaintext returns a version of this value that's been decrypted with the given key.

func (*Value) String

func (v *Value) String() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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