Documentation ¶
Index ¶
- Constants
- Variables
- func ChangePassword(name, password, newPassword string) (err error)
- func DeleteRecord(name string) error
- func GetHmacKey() (key []byte, err error)
- func GetSummary() (summary map[string]Summary)
- func GetVaultId() (id int, err error)
- func InitFromDisk(path string) error
- func IsInitialized() bool
- func MakeAdmin(name string) error
- func NumRecords() int
- func RevokeRecord(name string) error
- func SetRecord(pr PasswordRecord, name string)
- func WriteRecordsToDisk() error
- type ECPublicKey
- type PasswordRecord
- func (pr PasswordRecord) EncryptKey(in []byte) (out []byte, err error)
- func (pr PasswordRecord) GetKeyAES(password string) (key []byte, err error)
- func (pr PasswordRecord) GetKeyECC(password string) (key *ecdsa.PrivateKey, err error)
- func (pr PasswordRecord) GetKeyECCPub() (out *ecdsa.PublicKey, err error)
- func (pr PasswordRecord) GetKeyRSA(password string) (key rsa.PrivateKey, err error)
- func (pr PasswordRecord) GetKeyRSAPub() (out *rsa.PublicKey, err error)
- func (pr PasswordRecord) GetType() string
- func (pr PasswordRecord) IsAdmin() bool
- func (pr PasswordRecord) ValidatePassword(password string) error
- type Summary
Constants ¶
const ( AESRecord = "AES" RSARecord = "RSA" ECCRecord = "ECC" )
Constants for record type
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 ¶
var DefaultRecordType = ECCRecord
Functions ¶
func ChangePassword ¶
ChangePassword changes the password for a given user.
func GetHmacKey ¶
GetHmacKey returns the hmac key of the current vault.
func GetSummary ¶
GetSummary returns a summary of the records on disk.
func GetVaultId ¶
GetVaultId returns the id of the current vault.
func InitFromDisk ¶
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 RevokeRecord ¶
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 ECPublicKey ¶
type ECPublicKey struct { Curve *elliptic.CurveParams X, Y *big.Int }
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 } ECKey struct { ECPriv []byte ECPrivIV []byte ECPublic ECPublicKey } 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 or EC 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) GetKeyECC ¶
func (pr PasswordRecord) GetKeyECC(password string) (key *ecdsa.PrivateKey, err error)
GetKeyECC returns the ECDSA private key of the record given the correct password.
func (PasswordRecord) GetKeyECCPub ¶
func (pr PasswordRecord) GetKeyECCPub() (out *ecdsa.PublicKey, err error)
GetKeyECCPub returns the ECDSA public key out of the record.
func (PasswordRecord) GetKeyRSA ¶
func (pr PasswordRecord) GetKeyRSA(password string) (key rsa.PrivateKey, err error)
GetKeyRSA returns the RSA private key of the record given the correct password.
func (PasswordRecord) GetKeyRSAPub ¶
func (pr PasswordRecord) GetKeyRSAPub() (out *rsa.PublicKey, err error)
GetKeyRSAPub 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.