keypool

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: 5 Imported by: 0

Documentation

Overview

Package keypool implements a key generation and lookup service for blind signature keys

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned if the keyid could not be found in the keypool
	ErrNotFound = errors.New("keypool: not found")
	// ErrNoGenerator is returned if Current() is called on a keypool that has no private signature key
	ErrNoGenerator = errors.New("keypool: not a generator")
	// ErrBadUsage is returned if a key to load does not match the usage configuration
	ErrBadUsage = errors.New("keypool: bad usage setting of key")
	// ErrExpired is returned if a key has already expired
	ErrExpired = errors.New("keypool: expired key")
	// ErrBadSigner is returned if a key signature cannot be verified
	ErrBadSigner = errors.New("keypool: bad signature")
	// ErrExists is returned if a key to load is already loaded
	ErrExists = errors.New("keypool: key exists")
)

Functions

This section is empty.

Types

type FetchKeyCallBackFunc

type FetchKeyCallBackFunc func(keyid []byte) (marshalledKey []byte, err error)

FetchKeyCallBackFunc callback function to read keys from storage. Argument is the keyid, return is the marshalled key or error

type KeyPool

type KeyPool struct {
	Generator *signkeys.KeyGenerator
	KeyDir    string // Where to save keys

	VerifyPubKeys map[[ed25519.PublicKeySize]byte]bool // keys to verify against

	// FetchKeyCallBack callback function to read keys from storage.
	// Argument is the keyid, return is the marshalled key or error
	FetchKeyCallBack FetchKeyCallBackFunc
	// WriteKeyCallback callback function to write keys to storage.
	// Arguments are the keyid and the marshalled key
	WriteKeyCallback WriteKeyCallbackFunc
	// LoadKeysCallback callback function to load many keys from storage
	// Argument is the keypool to add the keys to
	LoadKeysCallback LoadKeysCallbackFunc
	// contains filtered or unexported fields
}

KeyPool implements a key pool configuration.

func New

func New(generator *signkeys.KeyGenerator) *KeyPool

New returns a new KeyPool. The generator may require additional settings (Usage, Expire). Those should be set before calling New.

func (*KeyPool) AddVerifyKey

func (kp *KeyPool) AddVerifyKey(key *[ed25519.PublicKeySize]byte)

AddVerifyKey adds key to the list of verification keys.

func (*KeyPool) Current

func (kp *KeyPool) Current() (*signkeys.KeyPair, *signkeys.KeyPair, error)

Current returns the current key and the previous key.

func (*KeyPool) HasVerifyKey

func (kp *KeyPool) HasVerifyKey(key *[ed25519.PublicKeySize]byte, nolock bool) bool

HasVerifyKey verifies that a verification key exists.

func (KeyPool) ListVerifyKeys

func (kp KeyPool) ListVerifyKeys() [][ed25519.PublicKeySize]byte

ListVerifyKeys lists all known verification keys.

func (*KeyPool) Load

func (kp *KeyPool) Load() error

Load calls the load callback chain to load keys from storage

func (*KeyPool) LoadKey

func (kp *KeyPool) LoadKey(loadKey *signkeys.PublicKey) (*[signkeys.KeyIDSize]byte, error)

LoadKey adds a single key to the keypool.

func (*KeyPool) LoadKeyUnsafe

func (kp *KeyPool) LoadKeyUnsafe(loadKey *signkeys.PublicKey) (*[signkeys.KeyIDSize]byte, error)

LoadKeyUnsafe adds a single key to the keypool. Without Mutex. be careful. only for use in callback.

func (*KeyPool) Lookup

func (kp *KeyPool) Lookup(keyid [signkeys.KeyIDSize]byte) (*signkeys.PublicKey, error)

Lookup a public key from keypool.

func (*KeyPool) RegisterStorage

func (kp *KeyPool) RegisterStorage(fetchFunc FetchKeyCallBackFunc, writeFunc WriteKeyCallbackFunc, loadFunc LoadKeysCallbackFunc)

RegisterStorage registers a storage backend.

func (KeyPool) SaveKey

func (kp KeyPool) SaveKey(keyid [signkeys.KeyIDSize]byte) error

SaveKey writes keyid to the keydir

func (KeyPool) SaveKeyUnsafe

func (kp KeyPool) SaveKeyUnsafe(keyid [signkeys.KeyIDSize]byte) error

SaveKeyUnsafe writes keyid to the keydir. Unsafe. No mutex. Only within callbacks.

func (KeyPool) WriteKey

func (kp KeyPool) WriteKey(key *signkeys.PublicKey) error

WriteKey calls the write callback chain to write keys to storage

type LoadKeysCallbackFunc

type LoadKeysCallbackFunc func(keypool *KeyPool) error

LoadKeysCallbackFunc callback function to load many keys from storage Argument is the keypool to add the keys to

type WriteKeyCallbackFunc

type WriteKeyCallbackFunc func(keyid []byte, usage string, marshalledKey []byte) error

WriteKeyCallbackFunc callback function to write keys to storage. Arguments are the keyid and the marshalled key

Directories

Path Synopsis
Package keydb implements a DB-based keypool storage backend.
Package keydb implements a DB-based keypool storage backend.
Package keydir implements a file-based keypool storage backend.
Package keydir implements a file-based keypool storage backend.
Package storagetests implements tests for the different keypool storage backends.
Package storagetests implements tests for the different keypool storage backends.

Jump to

Keyboard shortcuts

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