pwsafe

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2020 License: MIT Imports: 17 Imported by: 0

README

Password Safe v3 library

Documentation

Overview

Package pwsafe provides read/write access to Password Safe V3 databases. See https://en.wikipedia.org/wiki/Password_Safe for more information. Unsupported fields are preserved so that databases can be manipulated without losing information.

Per the V3 specification, HMAC only covers the header and record field data, but not the field type or length.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidDatabase = errors.New("invalid database")
)

Functions

This section is empty.

Types

type Header struct {
	Version           uint16
	UUID              [16]byte
	Name              string
	Description       string
	LastSaveTimestamp time.Time
	LastSaveByWhat    string
	LastSaveByUser    string
	LastSaveOnHost    string
	// Non-default preferences, tree display status, recently used entries,
	// empty groups
	UnimplementedFields []RawField
}

type PWSafeV3

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

func Decode

func Decode(b []byte, pass []byte, progressInterval time.Duration, progressFunc func(float64)) (*PWSafeV3, error)

Databases with high iterations can take a long time to decode. If progressInterval is > 0 and progressFunc != nil, progressFunc will be invoked with a value [0,100] every 'interval' duration.

func ReadFile

func ReadFile(path string, pass []byte) (*PWSafeV3, error)

func ReadFileWithPeriodicProgress

func ReadFileWithPeriodicProgress(path string, pass []byte, progressInterval time.Duration, progressFunc func(f float64)) (*PWSafeV3, error)

Databases with high iterations can take a long time to decode. If progressInterval is > 0 and progressFunc != nil, progressFunc will be invoked with a value [0,100] every 'interval' duration.

func (*PWSafeV3) Encode

func (db *PWSafeV3) Encode(pass []byte, iter uint32) ([]byte, error)

Useful for saving db to file

func (*PWSafeV3) Header

func (db *PWSafeV3) Header() Header

func (*PWSafeV3) Iterations

func (db *PWSafeV3) Iterations() uint32

func (*PWSafeV3) ListRecords

func (db *PWSafeV3) ListRecords() []Record

func (*PWSafeV3) SetDescription

func (db *PWSafeV3) SetDescription(s string) error

Returns error if s is not valid UTF8

func (*PWSafeV3) SetLastSaveBy

func (db *PWSafeV3) SetLastSaveBy(what, user, host string) error

Returns error if what, user, or host is not valid UTF8

func (*PWSafeV3) SetLastSaveTimestamp

func (db *PWSafeV3) SetLastSaveTimestamp(t time.Time)

func (*PWSafeV3) SetName

func (db *PWSafeV3) SetName(s string) error

Returns error if s is not valid UTF8

func (*PWSafeV3) SetUUID

func (db *PWSafeV3) SetUUID(uuid [16]byte)

func (*PWSafeV3) SetUnimplementedHeaderFields

func (db *PWSafeV3) SetUnimplementedHeaderFields(fields []RawField) error

Returns error if any field data length exceeds 32 bits

type RawField

type RawField struct {
	Kind uint8
	Data []byte
}

type Record

type Record struct {
	UUID           [16]byte
	Group          string
	Title          string
	Username       string
	Email          string
	Notes          string
	Pass           string
	CreationTime   time.Time
	PassModTime    time.Time
	LastAccessTime time.Time
	LastModTime    time.Time
	URL            string
	// Password expiry time, 'protected' status, autotype, password history,
	// password policy, double-click action, allowed symbols for password
	// generation, shift double-click action
	UnimplementedFields []RawField
}

TODO: aliases (3.3.3), shortcuts (3.3.4)

Jump to

Keyboard shortcuts

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