keepass

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package keepass reads and writes the KeePass1 database format.

Index

Constants

View Source
const (
	RijndaelCipher = kdbcrypt.RijndaelCipher
	TwofishCipher  = kdbcrypt.TwofishCipher
)

Ciphers for Options

Variables

View Source
var (
	ErrHashMismatch      = errors.New("keepass: password does not match or database is corrupt")
	ErrWrongSignature    = errors.New("keepass: not a KeePass file")
	ErrWrongVersion      = errors.New("keepass: unsupported version")
	ErrUnknownEncryption = errors.New("keepass: unknown encryption algorithm")
)

Errors

Functions

This section is empty.

Types

type Database

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

A Database represents a decrypted KDB file.

func New

func New(opts *Options) (*Database, error)

New creates a new empty database.

func Open

func Open(r io.Reader, opts *Options) (*Database, error)

Open decrypts and reads a database.

func (*Database) ComputedKey added in v0.2.2

func (db *Database) ComputedKey() kdbcrypt.ComputedKey

ComputedKey returns the computed encryption key of the database.

func (*Database) Entries added in v1.0.0

func (db *Database) Entries() []*Entry

Entries returns a list of all entries in the database.

func (*Database) Find

func (db *Database) Find(uuid [16]byte) *Entry

Find returns the entry that matches the UUID or nil if not found.

func (*Database) FindGroup

func (db *Database) FindGroup(id uint32) *Group

FindGroup returns the group that matches the group or nil if not found.

func (*Database) Root

func (db *Database) Root() *Group

Root returns the root group.

func (*Database) Write

func (db *Database) Write(w io.Writer) error

Write encodes the database to a writer.

type Entry

type Entry struct {
	UUID     uuids.UUID
	Title    string
	Icon     Icon
	URL      string
	Username string
	Password string
	Notes    string
	TimeInfo
	Attachment struct {
		Name string
		Data []byte
	}
	// contains filtered or unexported fields
}

An Entry stores a username and password.

func (*Entry) HasAttachment added in v1.0.0

func (e *Entry) HasAttachment() bool

HasAttachment reports whether an entry has a file attachment.

func (*Entry) Parent added in v1.0.0

func (e *Entry) Parent() *Group

Parent returns the entry's group.

func (*Entry) SetParent added in v1.0.0

func (e *Entry) SetParent(parent *Group) error

SetParent moves the entry to another group.

type Group

type Group struct {
	ID   uint32
	Name string
	Icon Icon
	TimeInfo
	// contains filtered or unexported fields
}

A Group is a hierarchial collection of entries.

func (*Group) Entries

func (g *Group) Entries() []*Entry

Entries returns the entries in the group as a slice.

func (*Group) Entry

func (g *Group) Entry(i int) *Entry

Entry returns the entry at index i. If i is out of range, this method will panic.

func (*Group) Group

func (g *Group) Group(i int) *Group

Group returns the group at index i. If i is out of range, this method will panic.

func (*Group) Groups

func (g *Group) Groups() []*Group

Groups returns the groups as a slice.

func (*Group) IsRoot added in v1.0.0

func (g *Group) IsRoot() bool

IsRoot reports whether the group is the database's root group.

func (*Group) NEntries

func (g *Group) NEntries() int

NEntries returns the number of entries this group has.

func (*Group) NGroups

func (g *Group) NGroups() int

NGroups returns the number of subgroups this group has.

func (*Group) NewEntry

func (g *Group) NewEntry() (*Entry, error)

NewEntry creates a new entry inside the group and returns it. An error is returned if the ID generation fails.

func (*Group) NewSubgroup

func (g *Group) NewSubgroup() *Group

NewSubgroup creates a group inside g and returns it.

func (*Group) Parent added in v1.0.0

func (g *Group) Parent() *Group

Parent returns the containing group or nil if the group is the database's root.

func (*Group) RemoveEntry

func (g *Group) RemoveEntry(e *Entry) error

RemoveEntry removes e from the group's entries.

func (*Group) RemoveSubgroup

func (g *Group) RemoveSubgroup(sub *Group) error

RemoveSubgroup removes sub from the group's children.

func (*Group) SetParent added in v1.0.0

func (g *Group) SetParent(parent *Group) error

SetParent moves the group to another group.

type Icon

type Icon uint32

type Options

type Options struct {
	// Password is an optional textual password to encrypt/decrypt
	// the database.
	Password string

	// KeyFile is an optional binary file to encrypt/decrypt the database.
	KeyFile io.Reader

	// If ComputedKey is non-nil, it will be used instead of Password/KeyFile
	// to decrypt an existing database.
	ComputedKey kdbcrypt.ComputedKey

	// Random number source, used for salts and ID generation.
	// Defaults to crypto/rand.Reader.
	Rand io.Reader

	// Number of rounds to encrypt the key with.  Higher values mean key
	// generation takes longer, thus harder to brute force.  If zero,
	// a reasonable default is used.  Only used for creation.
	KeyRounds int

	// Cipher to encrypt with.  Defaults to AES-256 (RijndaelCipher).
	// Only used for creation.
	Cipher kdbcrypt.Cipher

	// StaticIVForTesting will keep the IV the same between writes, useful
	// for testing, but insecure. Never enable this in production code!
	StaticIVForTesting bool
}

Options is the set of parameters for creating or opening a database. Nil is treated the same as the zero value.

type TimeInfo

type TimeInfo struct {
	LastModificationTime time.Time
	CreationTime         time.Time
	LastAccessTime       time.Time
	ExpiryTime           time.Time
}

TimeInfo holds all of the temporal data for a group or entry.

func (*TimeInfo) Expires

func (ti *TimeInfo) Expires() bool

Expires reports whether the item has an expiry.

Jump to

Keyboard shortcuts

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