keydb

package
v0.0.0-...-30b4a77 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2016 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package keydb defines an encrypted database used to store cryptographic keys.

Index

Constants

View Source
const (
	DBVersion = "Version" // version string of keydb
)

Entries in KeyValueTable.

View Source
const Version = "1"

Version is the current keydb version.

Variables

This section is empty.

Functions

func Create

func Create(dbname string, passphrase []byte, iter int) error

Create returns a new KEY database with the given dbname. It is encrypted by passphrase (processed by a KDF with iter many iterations).

func Rekey

func Rekey(dbname string, oldPassphrase, newPassphrase []byte, newIter int) error

Rekey tries to rekey the key database dbname with the newPassphrase (processed by a KDF with iter many iterations). The supplied oldPassphrase must be correct, otherwise an error is returned.

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 Open

func Open(dbname string, passphrase []byte) (*KeyDB, error)

Open opens the key database with dbname and passphrase.

func (*KeyDB) AddHashChainEntry

func (keyDB *KeyDB) AddHashChainEntry(
	domain string,
	position uint64,
	entry string,
) error

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

func (keyDB *KeyDB) AddPrivateUID(msg *uid.Message) error

AddPrivateUID adds a private uid to keyDB.

func (*KeyDB) AddPrivateUIDReply

func (keyDB *KeyDB) AddPrivateUIDReply(
	msg *uid.Message,
	msgReply *uid.MessageReply,
) error

AddPrivateUIDReply adds the msgReply to the given UID message.

func (*KeyDB) AddPublicKeyInit

func (keyDB *KeyDB) AddPublicKeyInit(ki *uid.KeyInit) error

AddPublicKeyInit adds a public KeyInit message to keyDB.

func (*KeyDB) AddPublicUID

func (keyDB *KeyDB) AddPublicUID(msg *uid.Message, position uint64) error

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

func (keyDB *KeyDB) AddSessionKey(
	hash, json, privKey string,
	cleanupTime uint64,
) error

AddSessionKey adds a session key to keyDB.

func (*KeyDB) AddValue

func (keyDB *KeyDB) AddValue(key, value string) error

AddValue adds a key-value pair to keyDB.

func (*KeyDB) Close

func (keyDB *KeyDB) Close() error

Close the key database.

func (*KeyDB) DelHashChain

func (keyDB *KeyDB) DelHashChain(domain string) error

DelHashChain deletes the hash chain for the given domain.

func (*KeyDB) DelMessageKey

func (keyDB *KeyDB) DelMessageKey(
	sessionKey string,
	sender bool,
	msgIndex uint64,
) error

DelMessageKey deletes the message key for the given sessionKey.

func (*KeyDB) DelPrivSessionKey

func (keyDB *KeyDB) DelPrivSessionKey(hash string) error

DelPrivSessionKey deletes the private key corresponding to the session key with given hash from keyDB.

func (*KeyDB) DelPrivateUID

func (keyDB *KeyDB) DelPrivateUID(msg *uid.Message) error

DelPrivateUID deletes the given UID message from keyDB.

func (*KeyDB) GetHashChainEntry

func (keyDB *KeyDB) GetHashChainEntry(domain string, position uint64) (string, error)

GetHashChainEntry returns the hash chain entry for the given domain and position from keydb.

func (*KeyDB) GetLastHashChainEntry

func (keyDB *KeyDB) GetLastHashChainEntry(domain string) (string, error)

GetLastHashChainEntry returns the last hash chain entry for the given domain.

func (*KeyDB) GetLastHashChainPos

func (keyDB *KeyDB) GetLastHashChainPos(domain string) (
	pos uint64,
	found bool,
	err error,
)

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

func (keyDB *KeyDB) GetPrivateIdentities() ([]string, error)

GetPrivateIdentities returns all private identities from keyDB.

func (*KeyDB) GetPrivateIdentitiesForDomain

func (keyDB *KeyDB) GetPrivateIdentitiesForDomain(domain string) ([]string, error)

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

func (keyDB *KeyDB) GetPublicKeyInit(sigKeyHash string) (*uid.KeyInit, error)

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

func (keyDB *KeyDB) GetSessionKey(hash string) (
	json, privKey string,
	err error,
)

GetSessionKey retrieves the session key with given hash from keyDB.

func (*KeyDB) GetSessionState

func (keyDB *KeyDB) GetSessionState(sessionStateKey string) (
	*session.State,
	error,
)

GetSessionState retrieves the session state for sessionStateKey from keyDB.

func (*KeyDB) GetValue

func (keyDB *KeyDB) GetValue(key string) (string, error)

GetValue gets the value for the given key from keyDB.

func (*KeyDB) Incremental

func (keyDB *KeyDB) Incremental(pages int64) error

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

func (keyDB *KeyDB) SetSessionState(
	sessionStateKey string,
	sessionState *session.State,
) error

SetSessionState adds or updates the given sessionState under sessionStateKey in keyDB.

func (*KeyDB) Status

func (keyDB *KeyDB) Status() (
	autoVacuum string,
	freelistCount int64,
	err error,
)

Status returns the autoVacuum mode and freelistCount of keyDB.

func (*KeyDB) Vacuum

func (keyDB *KeyDB) Vacuum(autoVacuumMode string) error

Vacuum executes VACUUM command in keyDB. If autoVacuumMode is not nil and different from the current one, the auto_vacuum mode is changed before VACUUM is executed.

func (*KeyDB) Version

func (keyDB *KeyDB) Version() (string, error)

Version returns the current version of keyDB.

Jump to

Keyboard shortcuts

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