keycache

package
v0.0.0-...-95e4144 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2015 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveUser

type ActiveUser struct {
	Usage
	Admin bool
	Type  string
	// contains filtered or unexported fields
}

ActiveUser holds the information about an actively delegated key.

type Cache

type Cache struct {
	UserKeys map[DelegateIndex]ActiveUser
}

Cache represents the current list of delegated keys in memory

func NewCache

func NewCache() Cache

NewCache initalizes a new cache.

func (*Cache) AddKeyFromRecord

func (cache *Cache) AddKeyFromRecord(record passvault.PasswordRecord, name, password string, users, labels []string, uses int, slot, durationString string) (err error)

AddKeyFromRecord decrypts a key for a given record and adds it to the cache.

func (*Cache) DecryptKey

func (cache *Cache) DecryptKey(in []byte, name, user string, labels []string, pubEncryptedKey []byte) (out []byte, err error)

DecryptKey decrypts a 16 byte key using the key corresponding to the name parameter For RSA and EC keys, the cached RSA/EC key is used to decrypt the pubEncryptedKey which is then used to decrypt the input buffer.

func (*Cache) DecryptShares

func (cache *Cache) DecryptShares(in [][]byte, name, user string, labels []string, pubEncryptedKey []byte) (out [][]byte, err error)

DecryptShares decrypts an array of 16 byte shares using the key corresponding to the name parameter.

func (*Cache) FlushCache

func (cache *Cache) FlushCache()

FlushCache removes all delegated keys.

func (*Cache) GetSummary

func (cache *Cache) GetSummary() map[string]ActiveUser

GetSummary returns the list of active user keys.

func (*Cache) MatchUser

func (cache *Cache) MatchUser(name, user string, labels []string) (ActiveUser, string, bool)

MatchUser returns the matching active user if present and a boolean to indicate its presence.

func (*Cache) Refresh

func (cache *Cache) Refresh()

Refresh purges all expired or used up keys.

func (*Cache) Valid

func (cache *Cache) Valid(name, user string, labels []string) (present bool)

Valid returns true if matching active user is present.

type DelegateIndex

type DelegateIndex struct {
	Name string
	Slot string
}

DelegateIndex is used to index the map of currently delegated keys. This is necessary to provide a way for a delegator to provide multiple delegations. It is also used to avoid the complexity of string parsing and enforcement of username and slot character requirements.

type Usage

type Usage struct {
	Uses   int       // Number of uses delegated
	Labels []string  // File labels allowed to decrypt
	Users  []string  // Set of users allows to decrypt
	Expiry time.Time // Expiration of usage
}

Usage holds the permissions of a delegated permission

Jump to

Keyboard shortcuts

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