vsafe

package module
v0.0.0-...-58ce9b1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2023 License: BSD-3-Clause Imports: 7 Imported by: 0

README

vsafe

An application to store passwords

Users Guide

Users guide available here.

Dependencies

A command line C compiler is needed.

Documentation

Overview

Package model provides the data structures for the vsafe app

Index

Constants

This section is empty.

Variables

View Source
var (
	// Wrong password provided for user.
	ErrWrongPassword = errors.New("vsafe: Wrong Password.")
	// Invalid key provided to decrypt an entry.
	ErrKeyMismatch = errors.New("vsafe: Key Mismatch.")
)

Functions

This section is empty.

Types

type Category

type Category struct {
	// Category id
	Id int64
	// The owner which corresponds to the master user ID.
	Owner int64
	// Category name
	Name string
}

Category represents a group of entries

type Entry

type Entry struct {
	// The ID of the entry
	Id int64
	// The owner of the entry which corresponds to the master user ID.
	Owner int64
	// The URL of the website. May be nil.
	Url *url.URL
	// The title
	Title string
	// The description
	Desc string
	// The user name
	UName string
	// The password
	Password string
	// Special instructions
	Special string
	// Categories to which this entry belongs
	Categories idset.IdSet
	// Etag
	Etag uint64
}

Entry represents an entry stored in the vsafe database. UName Password and Special fields are encrypted in persistent storage.

func (*Entry) Decrypt

func (e *Entry) Decrypt(key *Key) (err error)

Decrypt decrypts sensitive fields in this instance using key namely UName, Password, and Special. Decrypt returns ErrKeyMismatch if the provided key does not have the same Id as the key used to encrypt.

func (*Entry) Encrypt

func (e *Entry) Encrypt(key *Key) (err error)

Encrypt encrypts sensitive fields in this instance using key namely UName, Password, and Special

type EntryUpdater

type EntryUpdater func(*Entry) bool

EntryUpdater updates an entry in place and returns true on success.

type Key

type Key struct {
	Id    int64
	Value []byte
}

Key instances are used to encrypt / decrypt user name, password, and special fields in an entry. These instances must be treated as immutable.

func (*Key) Equal

func (k *Key) Equal(other *Key) bool

Equal returns true if this instance represents the same key as other. Otherwise Equal returns false.

type User

type User struct {
	// User ID
	Id int64
	// Master user lD. 0 means this user is also the master user. Users having
	// the same master are able to see the same entries in the database as the
	// ID of the key used to decrypt those entries corresponds to the master
	// user ID.
	Owner int64
	// The Name of this user.
	Name string
	// This user's encryption key encrypted by the user's own password.
	Key string
	// The checksum of the user's key. Used to verify that the password for
	// a user is correct.
	Checksum string
}

User instances represent a user of the vsafe app.

func (*User) ChangePassword

func (u *User) ChangePassword(oldPass, newPass string) error

ChangePassword changes the password of this user.

func (*User) GetOwner

func (u *User) GetOwner() int64

GetOwner returns the ID of the master user of this user. In the case that this user is a master user, GetOwner only works correctly after this user has been saved in persistent storage and has an ID.

func (*User) Init

func (u *User) Init(name, password string) error

Init initializes this user instance with a user name and password so that this user is a master user and has its own random key.

func (*User) InitWithKey

func (u *User) InitWithKey(name, password string, key *Key) (err error)

InitWithKey initializes this user instance with a user name and password so that the user uses key as its key.

func (*User) VerifyPassword

func (u *User) VerifyPassword(password string) (*Key, error)

VerifyPassword verifies that password is the password for this user. On success, it returns the key of this user.

Directories

Path Synopsis
Package aes provides encryption for the vsafe app.
Package aes provides encryption for the vsafe app.
apps
vsafe/common
Package common provides routines common to all handlers in the vsafe webapp.
Package common provides routines common to all handlers in the vsafe webapp.
vsafe/static
Package static provides static content for the vsafe app.
Package static provides static content for the vsafe app.
Package vsafedb handles storing instances in the vsafe app to persistent storage.
Package vsafedb handles storing instances in the vsafe app to persistent storage.
fixture
Package fixture provides test suites to test implementations of the datastore interfaces in the vsafedb package.
Package fixture provides test suites to test implementations of the datastore interfaces in the vsafedb package.
for_sqlite
Package for_sqlite provides a sqlite implementation of interfaces in vsafedb package.
Package for_sqlite provides a sqlite implementation of interfaces in vsafedb package.
sqlite_setup
Package sqlite_setup sets up a sqlite database for vsafe app
Package sqlite_setup sets up a sqlite database for vsafe app

Jump to

Keyboard shortcuts

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