passvault

package
v0.0.0-...-9c5d08f Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2013 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AESRecord = "AES"
	RSARecord = "RSA"
	ECCRecord = "ECC"
)

Constants for record type

View Source
const (
	KEYLENGTH = 16    // 16-byte output from scrypt
	N         = 16384 // Cost parameter
	R         = 8     // Block size
	P         = 1     // Parallelization factor

	DEFAULT_VERSION = 1
)

Constants for scrypt

Variables

This section is empty.

Functions

func ChangePassword

func ChangePassword(name, password, newPassword string) (err error)

ChangePassword changes the password for a given user.

func DeleteRecord

func DeleteRecord(name string) error

DeleteRecord deletes a given record.

func GetHmacKey

func GetHmacKey() (key []byte, err error)

GetHmacKey returns the hmac key of the current vault.

func GetSummary

func GetSummary() (summary map[string]Summary)

GetSummary returns a summary of the records on disk.

func GetVaultId

func GetVaultId() (id int, err error)

GetVaultId returns the id of the current vault.

func InitFromDisk

func InitFromDisk(path string) error

InitFromDisk reads the record from disk and initialize global context.

func IsInitialized

func IsInitialized() bool

IsInitialized returns true if the disk vault has been loaded.

func MakeAdmin

func MakeAdmin(name string) error

MakeAdmin adds admin status to a given record.

func NumRecords

func NumRecords() int

NumRecords returns the number of records in the vault.

func RevokeRecord

func RevokeRecord(name string) error

RevokeRecord removes admin status from a record.

func SetRecord

func SetRecord(pr PasswordRecord, name string)

SetRecord puts a record into the global status.

func WriteRecordsToDisk

func WriteRecordsToDisk() error

WriteRecordsToDisk saves the current state of the records to disk.

Types

type PasswordRecord

type PasswordRecord struct {
	Type           string
	PasswordSalt   []byte
	HashedPassword []byte
	KeySalt        []byte
	AESKey         []byte
	RSAKey         struct {
		RSAExp      []byte
		RSAExpIV    []byte
		RSAPrimeP   []byte
		RSAPrimePIV []byte
		RSAPrimeQ   []byte
		RSAPrimeQIV []byte
		RSAPublic   rsa.PublicKey
	}
	Admin bool
}

PasswordRecord is the structure used to store password and key material for a single user name. It is written and read from storage in JSON format.

func AddNewRecord

func AddNewRecord(name, password string, admin bool) (PasswordRecord, error)

AddNewRecord adds a new record for a given username and password.

func GetRecord

func GetRecord(name string) (PasswordRecord, bool)

GetRecord returns a record given a name.

func (PasswordRecord) EncryptKey

func (pr PasswordRecord) EncryptKey(in []byte) (out []byte, err error)

EncryptKey encrypts a 16-byte key with the RSA key of the record.

func (PasswordRecord) GetKeyAES

func (pr PasswordRecord) GetKeyAES(password string) (key []byte, err error)

GetKeyAES returns the 16-byte key of the record.

func (PasswordRecord) GetKeyRSA

func (pr PasswordRecord) GetKeyRSA(password string) (key rsa.PrivateKey, err error)

GetKeyAES returns the RSA private key of the record given the correct password.

func (PasswordRecord) GetKeyRSAPub

func (pr PasswordRecord) GetKeyRSAPub() (out *rsa.PublicKey, err error)

GetKeyAES returns the RSA public key of the record.

func (PasswordRecord) GetType

func (pr PasswordRecord) GetType() string

GetType returns the type status of the PasswordRecord.

func (PasswordRecord) IsAdmin

func (pr PasswordRecord) IsAdmin() bool

IsAdmin returns the admin status of the PasswordRecord.

func (PasswordRecord) ValidatePassword

func (pr PasswordRecord) ValidatePassword(password string) error

ValidatePassword returns an error if the password is incorrect.

type Summary

type Summary struct {
	Admin bool
	Type  string
}

Summary is a minmial account summary.

Jump to

Keyboard shortcuts

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