Documentation ¶
Overview ¶
Package keydb defines an encrypted database used to store cryptographic keys.
Index ¶
- Constants
- func Create(dbname string, passphrase []byte, iter int) error
- func Rekey(dbname string, oldPassphrase, newPassphrase []byte, newIter int) error
- type KeyDB
- func (keyDB *KeyDB) AddHashChainEntry(domain string, position uint64, entry string) error
- func (keyDB *KeyDB) AddPrivateKeyInit(ki *uid.KeyInit, pubKeyHash, sigPubKey, privateKey, serverSignature string) error
- func (keyDB *KeyDB) AddPrivateUID(msg *uid.Message) error
- func (keyDB *KeyDB) AddPrivateUIDReply(msg *uid.Message, msgReply *uid.MessageReply) error
- func (keyDB *KeyDB) AddPublicKeyInit(ki *uid.KeyInit) error
- func (keyDB *KeyDB) AddPublicUID(msg *uid.Message, position uint64) error
- func (keyDB *KeyDB) AddSession(sessionKey, rootKeyHash, chainKey string, send, recv []string) error
- func (keyDB *KeyDB) AddSessionKey(hash, json, privKey string, cleanupTime uint64) error
- func (keyDB *KeyDB) AddValue(key, value string) error
- func (keyDB *KeyDB) Close() error
- func (keyDB *KeyDB) DelHashChain(domain string) error
- func (keyDB *KeyDB) DelMessageKey(sessionKey string, sender bool, msgIndex uint64) error
- func (keyDB *KeyDB) DelPrivSessionKey(hash string) error
- func (keyDB *KeyDB) DelPrivateUID(msg *uid.Message) error
- func (keyDB *KeyDB) GetHashChainEntry(domain string, position uint64) (string, error)
- func (keyDB *KeyDB) GetLastHashChainEntry(domain string) (string, error)
- func (keyDB *KeyDB) GetLastHashChainPos(domain string) (pos uint64, found bool, err error)
- func (keyDB *KeyDB) GetMessageKey(sessionKey string, sender bool, msgIndex uint64) (string, error)
- func (keyDB *KeyDB) GetPrivateIdentities() ([]string, error)
- func (keyDB *KeyDB) GetPrivateIdentitiesForDomain(domain string) ([]string, error)
- func (keyDB *KeyDB) GetPrivateKeyInit(pubKeyHash string) (ki *uid.KeyInit, sigPubKey, privKey string, err error)
- func (keyDB *KeyDB) GetPrivateUID(identity string, withPrivkeys bool) (*uid.Message, *uid.MessageReply, error)
- func (keyDB *KeyDB) GetPublicKeyInit(sigKeyHash string) (*uid.KeyInit, error)
- func (keyDB *KeyDB) GetPublicUID(identity string, maxpos uint64) (msg *uid.Message, pos uint64, found bool, err error)
- func (keyDB *KeyDB) GetSession(sessionKey string) (rootKeyHash string, chainKey string, numOfKeys uint64, err error)
- func (keyDB *KeyDB) GetSessionKey(hash string) (json, privKey string, err error)
- func (keyDB *KeyDB) GetSessionState(sessionStateKey string) (*session.State, error)
- func (keyDB *KeyDB) GetValue(key string) (string, error)
- func (keyDB *KeyDB) Incremental(pages int64) error
- func (keyDB *KeyDB) SetSessionState(sessionStateKey string, sessionState *session.State) error
- func (keyDB *KeyDB) Status() (autoVacuum string, freelistCount int64, err error)
- func (keyDB *KeyDB) Vacuum(autoVacuumMode string) error
- func (keyDB *KeyDB) Version() (string, error)
Constants ¶
const (
DBVersion = "Version" // version string of keydb
)
Entries in KeyValueTable.
const Version = "1"
Version is the current keydb version.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type KeyDB ¶
type KeyDB struct {
// contains filtered or unexported fields
}
KeyDB is a handle for an encrypted database used to store mute keys.
func (*KeyDB) AddHashChainEntry ¶
AddHashChainEntry adds the hash chain entry at position for the given domain to keyDB.
func (*KeyDB) AddPrivateKeyInit ¶
func (keyDB *KeyDB) AddPrivateKeyInit( ki *uid.KeyInit, pubKeyHash, sigPubKey, privateKey, serverSignature string, ) error
AddPrivateKeyInit adds a private KeyInit message and the corresponding server signature to keyDB.
func (*KeyDB) AddPrivateUID ¶
AddPrivateUID adds a private uid to keyDB.
func (*KeyDB) AddPrivateUIDReply ¶
AddPrivateUIDReply adds the msgReply to the given UID message.
func (*KeyDB) AddPublicKeyInit ¶
AddPublicKeyInit adds a public KeyInit message to keyDB.
func (*KeyDB) AddPublicUID ¶
AddPublicUID adds a public UID message and it's hash chain position to keyDB.
func (*KeyDB) AddSession ¶
func (keyDB *KeyDB) AddSession( sessionKey, rootKeyHash, chainKey string, send, recv []string, ) error
AddSession adds a session for the given sessionKey. A session consists of a rootKeyHash, a chainKey and two arrays send and recv of sender and receiver keys. The arrays must have the same size.
func (*KeyDB) AddSessionKey ¶
AddSessionKey adds a session key to keyDB.
func (*KeyDB) DelHashChain ¶
DelHashChain deletes the hash chain for the given domain.
func (*KeyDB) DelMessageKey ¶
DelMessageKey deletes the message key for the given sessionKey.
func (*KeyDB) DelPrivSessionKey ¶
DelPrivSessionKey deletes the private key corresponding to the session key with given hash from keyDB.
func (*KeyDB) DelPrivateUID ¶
DelPrivateUID deletes the given UID message from keyDB.
func (*KeyDB) GetHashChainEntry ¶
GetHashChainEntry returns the hash chain entry for the given domain and position from keydb.
func (*KeyDB) GetLastHashChainEntry ¶
GetLastHashChainEntry returns the last hash chain entry for the given domain.
func (*KeyDB) GetLastHashChainPos ¶
GetLastHashChainPos returns the last hash chain position for the given domain from keydb. The return value found indicates if a hash chain entry for domain exists.
func (*KeyDB) GetMessageKey ¶
func (keyDB *KeyDB) GetMessageKey( sessionKey string, sender bool, msgIndex uint64, ) (string, error)
GetMessageKey returns the message key for the given sessionKey.
func (*KeyDB) GetPrivateIdentities ¶
GetPrivateIdentities returns all private identities from keyDB.
func (*KeyDB) GetPrivateIdentitiesForDomain ¶
GetPrivateIdentitiesForDomain returns all private identities for the given domain from keyDB.
func (*KeyDB) GetPrivateKeyInit ¶
func (keyDB *KeyDB) GetPrivateKeyInit( pubKeyHash string, ) (ki *uid.KeyInit, sigPubKey, privKey string, err error)
GetPrivateKeyInit returns the private KeyInit for the given pubKeyHash.
func (*KeyDB) GetPrivateUID ¶
func (keyDB *KeyDB) GetPrivateUID( identity string, withPrivkeys bool, ) (*uid.Message, *uid.MessageReply, error)
GetPrivateUID gets a private uid for identity from keyDB.
TODO: get all UID messages for given identity which are not expired.
func (*KeyDB) GetPublicKeyInit ¶
GetPublicKeyInit gets a public key init from keydb. If no such KeyInit could be found, sql.ErrNoRows is returned.
func (*KeyDB) GetPublicUID ¶
func (keyDB *KeyDB) GetPublicUID( identity string, maxpos uint64, ) (msg *uid.Message, pos uint64, found bool, err error)
GetPublicUID gets the public UID message from keyDB with the highest position smaller or equal to maxpos.
func (*KeyDB) GetSession ¶
func (keyDB *KeyDB) GetSession(sessionKey string) ( rootKeyHash string, chainKey string, numOfKeys uint64, err error, )
GetSession returns the session for the given sessionKey.
func (*KeyDB) GetSessionKey ¶
GetSessionKey retrieves the session key with given hash from keyDB.
func (*KeyDB) GetSessionState ¶
GetSessionState retrieves the session state for sessionStateKey from keyDB.
func (*KeyDB) Incremental ¶
Incremental executes incremental_vacuum to free up to pages many pages. If pages is 0, all pages are freed. If the current auto_vacuum mode is not INCREMENTAL, an error is returned.
func (*KeyDB) SetSessionState ¶
SetSessionState adds or updates the given sessionState under sessionStateKey in keyDB.